Relative links in Markdown files don't work according to a spec if they point to files that don't exist in repo

Summary

  1. Given: Making changes to a Markdown file in a repo located at: https://example.com/dreamhost/virtkick/kubekick/blob/master/docs/50-troubleshooting.md
  2. When: Markdown link to URL /docs/0-setup.md#step-5-inspect-logs
  3. Then: render HTML link to URL https://example.com/dreamhost/virtkick/kubekick/blob/master/docs/0-setup.md#step-5-inspect-logs
  4. Actual: render HTML link to URL `https://example.com/dreamhost/virtkick/kubekick/master/docs/0-setup.md#step-5-inspect-logs``

Context: this ONLY happens if docs/0-setup.md doesn't exit in the repo. If docs/0-setup.md exists, the link is correct.

Steps to reproduce

  1. Edit any Markdown file in GitLab visual editor.
  2. Add anywhere: [Kubekick guide, Inspect logs](/docs/0-setup.md#step-5-inspect-logs)
  3. Click Preview.
  4. Hover on the new link.
  5. Note the generated URL is missing the blob part.

image

GitLab: 11.6.2-ee

Why it matters?

<DevilsAdvocate666> If I'm linking to a file that doesn't exist, why does it matter that the generated URL is still up to spec?

Because when I first make a mistake, and link to 0-setup.md instead of 10-setup.md, I'll check a link and it'll be invalid. If I spot lack of /blob/ part in the link instead of my human typo 10 vs 0, I'll think it's GitLab to blame, take down the company for GitLab upgrade (to make sure it's not a bug in GitLab), and when still not working, submit THIS ticket, only to realize that it was a typo at later point (but GitLab's inconsistency in generating links too).

Mentions

@markglenfletcher @jramsay gitlab-ce2278648 gitlab-ce4107676 gitlab-ce~4107755

Edited by Damian Nowak