From 752887b9a7a8158d0c9e140d93877017e2fc2a69 Mon Sep 17 00:00:00 2001 From: Frank Sauerburger Date: Tue, 12 Feb 2019 12:44:14 +0100 Subject: Update RE used to prefix links with /help/ Update the regular expression in the help controller used to prefix relative links on the help page with /help/. As suggested by @rymai, the look-ahead pattern to detect external links is simplified from `[a-zA-Z0-9.+-]` to `\w`. --- app/controllers/help_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 53e023714b3..a9d6addd4a4 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -14,10 +14,9 @@ class HelpController < ApplicationController @help_index = File.read(Rails.root.join('doc', 'README.md')).sub(YAML_FRONT_MATTER_REGEXP, '') # Prefix Markdown links with `help/` unless they are external links. - # RFC3986 allows alphanumeric, '+', '-' and '.' for URL schema; # '//' not necessarily part of URL, e.g., mailto:mail@example.com - # See https://rubular.com/r/C5wTz0gE5r6x0f - @help_index.gsub!(%r{(?\]\()(?![a-zA-Z0-9.+-]+:)(?!/)(?[^\)\(]+\))}) do + # See https://rubular.com/r/DFHZl5w8d3bpzV + @help_index.gsub!(%r{(?\]\()(?!\w+:)(?!/)(?[^\)\(]+\))}) do "#{$~[:delim]}#{Gitlab.config.gitlab.relative_url_root}/help/#{$~[:link]}" end end -- cgit v1.2.1