gr-dropdown: Prevent adding base url twice in _computeURLHelper

This will be used to prevent adding a base url twice to a path,
it will be used by the download binary dropdown change done in [1].

Because one of the function uses changeBaseURL it adds the base url
already.

[1] I4e05dba0dcfaf8699e20f151a6949ffb08701bbe

Bug: Issue 6029
Change-Id: I6f2eff09bd4a4581926fcdce4ceb03ed2e1afc85
This commit is contained in:
Paladox none
2019-09-27 16:34:50 +00:00
committed by Paladox
parent 963b2c9bd3
commit b77e26cae3

View File

@@ -198,14 +198,16 @@
},
/**
* Build a URL for the given host and path. If there is a base URL, it will
* be included between the host and the path.
* Build a URL for the given host and path. The base URL will be only added,
* if it is not already included in the path.
* @param {!string} host
* @param {!string} path
* @return {!string} The scheme-relative URL.
*/
_computeURLHelper(host, path) {
return '//' + host + this.getBaseUrl() + path;
const base = path.startsWith(this.getBaseUrl()) ?
'' : this.getBaseUrl();
return '//' + host + base + path;
},
/**