Skip to content

Commit 757f47a

Browse files
committed
strip off extra # or ? from base url pathname before adding /
1 parent b1e70dd commit 757f47a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/util/submit-addon.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ export default class Client {
9090
userAgentString,
9191
}: ClientConstructorParams) {
9292
this.apiAuth = apiAuth;
93-
if (!baseUrl.href.endsWith('/')) {
94-
baseUrl = new URL(`${baseUrl.href}/`);
93+
if (!baseUrl.pathname.endsWith('/')) {
94+
baseUrl = new URL(baseUrl.href);
95+
baseUrl.pathname += '/';
9596
}
9697
this.apiUrl = new URL('addons/', baseUrl);
9798
this.validationCheckInterval = validationCheckInterval;

tests/unit/test-util/test.submit-addon.js

+7
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ describe('util.submit-addon', () => {
250250
);
251251
});
252252

253+
it('drops extra characters on baseUrl before setting apiUrl', () => {
254+
const cleanUrl = 'http://url.with/extra';
255+
const extraBaseUrl = new URL(`${cleanUrl}#?`);
256+
const client = new Client({ ...clientDefaults, baseUrl: extraBaseUrl });
257+
assert.equal(client.apiUrl.href, new URL(`${cleanUrl}/addons/`).href);
258+
});
259+
253260
describe('doUploadSubmit', () => {
254261
it('submits the xpi', async () => {
255262
const client = new Client(clientDefaults);

0 commit comments

Comments
 (0)