Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

Raw urls on GitHub keep changing

I need a Markdown file to be able to refer to diagrams in my repository and for the links to remain valid as the diagrams are updated. I am finding that the url I get when I right-click the Raw button and copy the link varies between these two forms:

https://github.com/user/repo/raw/branch/folder/file.png
https://raw.github.com/user/repo/branch/folder/file.png

Note the change in the position of "raw".

Could anyone explain, please, what is happening?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One of these URLs is a redirect to the other, or they're both in a redirect chain to a third link. It's possible your browser has prefetched one and knows the destination already in some cases, and not in others.

I'd take either one to a command-line prompt and give it to curl -Lv and see where the final one ends up. Alternately, you can use the API to query for the raw link for this object, and whatever it gives you should be correct.

I will tell you that the latter domain name is probably not correct; I would suspect that the right URL is at the domain raw.githubusercontent.com, but I'd ask the API to be sure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...