Accept GitHub source URL format for code highlights
Release notes
Some code editor plugins, such as GitLink for JetBrains IDEs, provide actions that allow generating a link from the selected text range. Previously, such links from GitHub could not be used as-is for GitLab repositories because the GitLab UI did not correctly interpret the GitHub format. This was frustrating because you had to manually modify the URL to the correct format for the link to be highlighted. We have improved GitLab repositories to recognize and accept the format for URLs from GitHub sources.
https://docs.gitlab.com/ee/development/
Summary
In GitLab, generated URLs containing highlighted lines follow the <file URL>?L<starting line number>-<ending line number>
format (e.g. https://gitlab.com/gitlab-org/gitlab/-/blob/master/lefthook.yml#L6-10):
Some well-known code editor plugins provide actions that allow generating such a link from the selected text range (an example being GitLink for JetBrains IDEs). Unfortunately, such links cannot be used as-is for GitLab repositories because the GitLab UI doesn't correctly interpret the GitHub format (which adds an L
to the ending line number: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lefthook.yml#L6-L10). When such a link is clicked in GitLab, no highlight happens and the user must manually fix the URL by adding the L
so that highlighting works. This is less than ideal and we should support both formats in app/assets/javascripts/line_highlighter.js
.