зеркало из https://github.com/mozilla/normandy.git
recipe-client-addon: Use URL object to manipulate URLs.
This commit is contained in:
Родитель
db0dd1b32f
Коммит
ff075eaabe
|
@ -62,12 +62,12 @@ this.NormandyApi = {
|
|||
},
|
||||
|
||||
async getApiUrl(name) {
|
||||
let apiBase = prefs.getCharPref("api_url");
|
||||
if (!apiBase.endsWith('/')) {
|
||||
apiBase += '/';
|
||||
let apiBase = new URL(prefs.getCharPref("api_url"));
|
||||
if (!apiBase.pathname.endsWith('/')) {
|
||||
apiBase.pathname += '/';
|
||||
}
|
||||
if (!indexPromise) {
|
||||
indexPromise = this.get(apiBase).then(res => res.json());
|
||||
indexPromise = this.get(apiBase.toString()).then(res => res.json());
|
||||
}
|
||||
const index = await indexPromise;
|
||||
if (!(name in index)) {
|
||||
|
|
|
@ -105,7 +105,7 @@ add_task(withMockApiServer(async function test_getApiUrlSlashes(serverUrl, prefe
|
|||
equal(endpoint, `${serverUrl}/test/`);
|
||||
ok(mockGet.calledWithExactly(`${serverUrl}/api/v1/`), "trailing slash was added");
|
||||
mockGet.reset();
|
||||
};
|
||||
}
|
||||
|
||||
// with slash
|
||||
{
|
||||
|
@ -117,6 +117,7 @@ add_task(withMockApiServer(async function test_getApiUrlSlashes(serverUrl, prefe
|
|||
mockGet.reset();
|
||||
}
|
||||
|
||||
NormandyApi.clearIndexCache();
|
||||
mockGet.restore();
|
||||
}));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче