From 78379f66ddbb2a1784e55533159993d5460f18a4 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 28 Jun 2017 14:01:39 -0500 Subject: [PATCH] Strip trailing whitespace in relative submodule URL --- app/helpers/submodule_helper.rb | 1 + .../dm-relative-submodule-url-trailing-whitespace.yml | 4 ++++ spec/helpers/submodule_helper_spec.rb | 5 +++++ 3 files changed, 10 insertions(+) create mode 100644 changelogs/unreleased/dm-relative-submodule-url-trailing-whitespace.yml diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 8e0a1e2ecdf..b24039fb349 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -73,6 +73,7 @@ module SubmoduleHelper end def relative_self_links(url, commit) + url.rstrip! # Map relative links to a namespace and project # For example: # ../bar.git -> same namespace, repo bar diff --git a/changelogs/unreleased/dm-relative-submodule-url-trailing-whitespace.yml b/changelogs/unreleased/dm-relative-submodule-url-trailing-whitespace.yml new file mode 100644 index 00000000000..616241dd941 --- /dev/null +++ b/changelogs/unreleased/dm-relative-submodule-url-trailing-whitespace.yml @@ -0,0 +1,4 @@ +--- +title: Strip trailing whitespace in relative submodule URL +merge_request: +author: diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb index cb727430117..9e561d0f191 100644 --- a/spec/helpers/submodule_helper_spec.rb +++ b/spec/helpers/submodule_helper_spec.rb @@ -170,6 +170,11 @@ describe SubmoduleHelper do expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) end + it 'with trailing whitespace' do + result = relative_self_links('../test.git ', commit_id) + expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) + end + it 'two levels down' do result = relative_self_links('../../test.git', commit_id) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])