Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@
* limitations under the License.
*/

let root;
if (typeof window !== 'undefined') {
root = window;
} else if (typeof global !== 'undefined') {
/**
* Ensure that `URL` & `URLSearchParams` constructors are globally available
* @see https://nodejs.org/api/globals.html#globals_url
* @see https://nodejs.org/api/globals.html#globals_urlsearchparams
*/
const { URL, URLSearchParams } = require('url');
global.URL = global.URL || URL;
global.URLSearchParams = global.URLSearchParams || URLSearchParams;
root = global;
} else if (typeof self !== 'undefined') {
root = self;
} else {
root = this;
}

export { default as parse } from './parse';
export { default as format } from './format';
export { resolve, resolveObject } from './resolve';
export const { URL } = root;
export const { URLSearchParams } = root;