microsoft / linkcheckermd

A VSCode extension that check links in Markdown to ensure they are valid.
MIT License
16 stars 20 forks source link

GitHub links #16

Closed seanmcbreen closed 4 years ago

seanmcbreen commented 8 years ago

This is a little tricky but GitHub links need a little massaging...

This is the correct link...

https://github.com/Microsoft/vscode-extensionbuilders/blob/master/docs/extensionAPI/extension-manifest.md#gallery-presentation-tips

You test this link... [missing the /blob/branch name/...]

https://github.com/Microsoft/vscode-extensionbuilders/docs/extensionAPI/extension-manifest.md#gallery-presentation-tips

Another option for relative links is to actually check the file exists on the disk for that repo via a node file all.

Blackmist commented 8 years ago

@seanmcbreen can you give me steps to reproduce? I'm not fully understanding the problem other than it involves git/github specific paths.

Thanks, Larry

Blackmist commented 8 years ago

Hrmmmmmm, so looking at this more, I think what you're asking for is:

  1. I'm typing a document, and I'm trying to link to a file on GitHub.
  2. I've typed the URI in, but forgotten that I need /blob/BRANCHNAME in the URI
  3. Please flag this as green/red so I'll notice and fix.

Sound correct?

seanmcbreen commented 8 years ago

Actually a little different I observed that the links that were being checked for Github (in the ourput window) were missing the required content to ensure they worked (the branch) so there were some false readings for those links. This was in the conversion of relative to absolute URLS.

Blackmist commented 8 years ago

The branch portion should be added automatically when they are hosted on GitHub. For example, if you look at https://github.com/Microsoft/azure-content/blob/master/articles/HDInsight/hdinsight-use-hive.md and scroll to the table with links at the end. If you look at the raw HTML, none of them have /branch/master or anything like that in the path. They are all for files in the same folder. If you need to link to something in another folder, these use a relative path similar to ../otherfolder/file.md.

Now, the one case I can think that this would cause a problem is if you are going all the way to the root with your relative path. For example, /somefolder/someotherfolder/filename.md. For that, depending on how the hosting site is set up, you might have to have or infer some knowledge about the URL structure for the site.

I'll do some testing. Maybe the answer is a configuration property that is set. Something like "hosting-site-root-URI" where you can put /blob/branchname, and then having the extension use that when verifying paths. Any relative path that begins with / would invoke that rule to verify that it began with the configured value.

Sound accurate/ok?