Skip to content

Commit

Permalink
Allow custom HTTP base API URLs to get HTTP responses (#10090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Hamley authored Nov 12, 2020
1 parent 94e4714 commit 8066104
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/util/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ export class RequestManager {
urlObject.protocol = apiUrlObject.protocol;
urlObject.authority = apiUrlObject.authority;

if (urlObject.protocol === 'http') {
const i = urlObject.params.indexOf('secure');
if (i >= 0) urlObject.params.splice(i, 1);
}

if (apiUrlObject.path !== '/') {
urlObject.path = `${apiUrlObject.path}${urlObject.path}`;
}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/util/mapbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ test("mapbox", (t) => {
t.end();
});

t.test('removes secure params if custom API_URL is http', (t) => {
config.API_URL = 'http://test.example.com/api.mapbox.com';
t.equal(
manager.normalizeSourceURL('mapbox://one.a'),
'http://test.example.com/api.mapbox.com/v4/one.a.json?access_token=key'
);
t.end();
});

t.end();
});

Expand Down

0 comments on commit 8066104

Please sign in to comment.