- Fix issue in Firefox 57 when run from static build - Fix color parameter in dynamic badge maker - Correctly apply maxAge in usage badges - Follow the WHATWG lead and begin to standardize on URL, not URI (https://url.spec.whatwg.org/#goals)
15 lines
632 B
JavaScript
15 lines
632 B
JavaScript
// I played with build-url and url-resolve-browser and neither of them did the
|
|
// right thing. Previously this was based on url-path, which patched around
|
|
// the URL API. This caused problems in Firefox 57, but only in the production
|
|
// build.
|
|
import { resolve, parse, format } from 'url';
|
|
|
|
// baseUrl and queryParams are optional.
|
|
export default function resolveUrl (url, baseUrl, queryParams) {
|
|
const resolved = baseUrl ? resolve(baseUrl, url) : url;
|
|
const parsed = parse(resolved, /* parseQueryString */ true);
|
|
parsed.query = Object.assign({}, parsed.query, queryParams);
|
|
delete parsed.search;
|
|
return format(parsed);
|
|
}
|