Commit e935635620cbc4a3f2f18303f12891cc997f1cb1

Authored by Timm Drevensek
1 parent fe8c9021

fixed regex to match url pointing to a user repo

Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
app/helpers/submodule_helper.rb
... ... @@ -39,8 +39,8 @@ module SubmoduleHelper
39 39 end
40 40  
41 41 def relative_self_url?(url)
42   - # (./)? ( (../repo.git) | (../../project/repo.git) )
43   - url =~ /(^((\.\/)?(((\.\.)\/)|((\.\.)\/(\.\.)\/.*\/)))[^\.\/]*\.git)\Z/
  42 + # (./)?(../repo.git) || (./)?(../../project/repo.git) )
  43 + url =~ /^((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\Z/ || url =~ /^((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\Z/
44 44 end
45 45  
46 46 def standard_links(host, project, commit)
... ... @@ -49,7 +49,7 @@ module SubmoduleHelper
49 49 end
50 50  
51 51 def relative_self_links(url, commit)
52   - if url.scan(/(\.\.)/).size == 2
  52 + if url.scan(/(\.\.\/)/).size == 2
53 53 base = [ Gitlab.config.gitlab.url, '/', url[/.*\/(.*)\/.*\.git/, 1] ].join('')
54 54 else
55 55 base = [ Gitlab.config.gitlab.url, '/', @project.group.path ].join('')
... ...