From a38cf29c490b0215ce9caac06c4f8ef783e519d8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 5 May 2022 12:27:07 +0200 Subject: [PATCH] feat: opt-in support of whatwg-url mock (#15) --- README.md | 3 +-- src/runtime/npm/whatwg-url.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/runtime/npm/whatwg-url.ts diff --git a/README.md b/README.md index 8338cccb..c631845c 100644 --- a/README.md +++ b/README.md @@ -89,8 +89,7 @@ Module | Status | Source [npm/mime](https://www.npmjs.com/package/mime) | Polyfilled | [unenv/runtime/npm/mime](./src/runtime/npm/mime.ts) [npm/node-fetch](https://www.npmjs.com/package/node-fetch) | Replace with Platform Native | [unenv/runtime/npm/node-fetch](./src/runtime/npm/node-fetch.ts) [npm/cross-fetch](https://www.npmjs.com/package/node-fetch) | Replace with Platform Native | [unenv/runtime/npm/cross-fetch](./src/runtime/npm/cross-fetch.ts) - - +[npm/whatwg-url](https://www.npmjs.com/package/whatwg-url) | opt-in | [unenv/runtime/npm/whatwg-url](./src/runtime/npm/whatwg-url.ts) ## Auto-mocking proxy diff --git a/src/runtime/npm/whatwg-url.ts b/src/runtime/npm/whatwg-url.ts new file mode 100644 index 00000000..39b7664a --- /dev/null +++ b/src/runtime/npm/whatwg-url.ts @@ -0,0 +1,20 @@ +// https://www.npmjs.com/package/whatwg-url + +export const URL = globalThis.URL +export const URLSearchParams = globalThis.URLSearchParams + +function notSupported () { + throw new Error('[unenv] whatwg-url low level API is not supported yet!') +} + +export const parseURL = notSupported +export const basicURLParse = notSupported +export const serializeURL = notSupported +export const serializeHost = notSupported +export const serializeInteger = notSupported +export const serializeURLOrigin = notSupported +export const setTheUsername = notSupported +export const setThePassword = notSupported +export const cannotHaveAUsernamePasswordPort = notSupported +export const percentDecodeBytes = notSupported +export const percentDecodeString = notSupported