diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index ca7b87b69adfa939c8c03a7eaae57fe9094a4bb9..d7a253fac898e518471237d7855b9d4bb8c308d9 100755 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -39,8 +39,8 @@ module SubmoduleHelper end def relative_self_url?(url) - # (./)? ( (../repo.git) | (../../project/repo.git) ) - url =~ /(^((\.\/)?(((\.\.)\/)|((\.\.)\/(\.\.)\/.*\/)))[^\.\/]*\.git)\Z/ + # (./)?(../repo.git) || (./)?(../../project/repo.git) ) + url =~ /^((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\Z/ || url =~ /^((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\Z/ end def standard_links(host, project, commit) @@ -49,7 +49,7 @@ module SubmoduleHelper end def relative_self_links(url, commit) - if url.scan(/(\.\.)/).size == 2 + if url.scan(/(\.\.\/)/).size == 2 base = [ Gitlab.config.gitlab.url, '/', url[/.*\/(.*)\/.*\.git/, 1] ].join('') else base = [ Gitlab.config.gitlab.url, '/', @project.group.path ].join('')