diff options
author | Paul Slaughter <pslaughter@gitlab.com> | 2019-04-24 12:30:46 -0500 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2019-04-24 13:05:29 -0500 |
commit | 4abd43609795e1cc0652396b6a00bc38ed237371 (patch) | |
tree | e5fa007d8022e1bcd3512c6c33757be7bbd981da /spec | |
parent | 8b2592ee744438711f449062ff2dc26101e57833 (diff) | |
download | gitlab-ce-4abd43609795e1cc0652396b6a00bc38ed237371.tar.gz |
Fix API and IDE path with `/` relative_url_root
**Why?**
Previously we simply concatenated our paths, which led
to requesting `//api/v4/...` and obviously failed. The BE
supports a relative_url_root of `/`. It's a bug that the FE
does not.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/api_spec.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index e537e0e8afc..494b3b934a8 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -4,7 +4,7 @@ import Api from '~/api'; describe('Api', () => { const dummyApiVersion = 'v3000'; - const dummyUrlRoot = 'http://host.invalid'; + const dummyUrlRoot = '/gitlab'; const dummyGon = { api_version: dummyApiVersion, relative_url_root: dummyUrlRoot, @@ -32,6 +32,18 @@ describe('Api', () => { expect(builtUrl).toEqual(expectedOutput); }); + + [null, '', '/'].forEach(root => { + it(`works when relative_url_root is ${root}`, () => { + window.gon.relative_url_root = root; + const input = '/api/:version/foo/bar'; + const expectedOutput = `/api/${dummyApiVersion}/foo/bar`; + + const builtUrl = Api.buildUrl(input); + + expect(builtUrl).toEqual(expectedOutput); + }); + }); }); describe('group', () => { |