Files
shields/frontend/lib/resolve-url.js
dependabot[bot] 5a367efe11 Bump eslint-plugin-node from 7.0.1 to 8.0.0 (#2225)
* Bump eslint-plugin-node from 7.0.1 to 8.0.0

Bumps [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) from 7.0.1 to 8.0.0.
- [Release notes](https://github.com/mysticatea/eslint-plugin-node/releases)
- [Commits](https://github.com/mysticatea/eslint-plugin-node/compare/v7.0.1...v8.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Update lockfile

* Temporarily ignore…
2018-11-19 16:15:47 -05:00

18 lines
726 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.
// Let's rewrite these without a deprecated API!
// eslint-disable-next-line node/no-deprecated-api
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)
}