Skip to content

Wiki search breaks with hierarchical paths

Summary

The search results page incorrectly uses the basename of wiki results instead of simply dropping the extension.

Steps to reproduce

  1. Create a wiki page with a directory component (e.g. hello/test.md)
  2. Use the search interface to find the page
  3. Click on the result; you will be taken to a 404 as the target of the link is /$PROJECT/wikis/test rather than /$PROJECT/wikis/hello/test)

Example Project

What is the current bug behavior?

Search results point to nonexistent wiki pages.

What is the expected correct behavior?

Search results point to the existent pages.

Output of checks

This bug happens on GitLab.com

Possible fixes

The problem appears to be that app/views/search/results/_wiki_blob.html.haml uses the blob's basename as the link target. This was likely intended to merely remove the file extension however has the effect of also removing the path's directory component.