So many broken links makes meta more difficult to use. Considering these links are typically posted by the Discourse founders, all the more likely to be followed into the future…
There are probably some exceptions that you’re 99% sure will stay around, such as README.md, but search for “https://github.com/discourse/discourse/blob/master/” and see how many of these are no longer valid.
Yes, links break over time. This is not specific to meta, or Discourse, or even Github. Does Github provide a stable means of determining whether a URL is a permalink based on its structure? If not, it’s going to be awfully tricky to implement a warning.
If the returned SHA is equal to :commit itself, then it’s a permalink. Otherwise, it’s not. Personally, I’d just rewrite non-permalinks into permalinks automatically, though.
There doesn’t seem to be a straightforward way to get a permanent link from the entered GitHub link if we wanted to rewrite links into permalink automatically. I guess checking if the link is permalink like @notriddle suggested and adding a warning would be a way to go here?
Can you give us a fully-worked example of how to go from a /tree/ link to a /blob/ link programmatically? I can’t figure it out from the examples provided.