Skip to content

relative links in markdown to the current directory or via subdir/.. do not work (as expected)

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

Relative links in markdown files in regular repositories given as "./" or "subdir/../" do not point to the tree view of the directory the markdown file is in, but instead to the project root.

Steps to reproduce

  • create a new project (or re-use a project if you like)
  • create a subdirectory subdir within the repo of that project and a subdirectory subsubdir within that.
  • create a markdown file (lets call it linktest.md) in subdir containing relative links to ./, subsubdir/../ and ./subsubdir/../.
  • view the file in the web previewer on gitlab and observe the links to now go to PROJECT_ROOT/-/blob/main/ instead of PROJECT_ROOT/-/tree/main/subdir

Example Project

https://gitlab.com/knarrff/link_test/-/blob/main/subdir/linktest.md

What is the current bug behavior?

The relative link is translated incorrectly to the root of the project instead of the current directory. Relative links to the current directory work via its parent: ../subdir/. Relative links to files ./linktest.md or linktest.md do work, as do links to subdirectories ./subsubdir/ or subsubdir/. What also does not work is using a child instead of a parent directory to link to the current directory: subsubdir/../ also points to the (wrong) project root.

This happens both at a self-hosted instance (GitLab Community Edition 14.10.2) as well as gitlab.com, as demonstrated in the test repository mentioned above.

What is the expected correct behavior?

The relative link should point to the current directory (tree view) using ./, . (and subdir/../, ./subdir/../ or similar, assuming subdir exists in that directory).

Edited by 🤖 GitLab Bot 🤖