From ea06d9a7413f049a6c7f06b21cc5e064809ff3f7 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 6 Feb 2024 19:12:44 +0100 Subject: [PATCH 1/2] feat: add toString column shortens test values, limits test to long example --- README.md | 303 ++++++++++-------------------------- bin/update-readme.js | 2 +- package.json | 2 +- src/create-table-results.ts | 18 ++- test/urls.spec.js | 177 +++++++++++---------- 5 files changed, 184 insertions(+), 318 deletions(-) diff --git a/README.md b/README.md index 64570a8..e8ee896 100644 --- a/README.md +++ b/README.md @@ -18,257 +18,120 @@ To update the below results, run `npm run update-results` The following tables are generated from the test suite. -### Grouped by URL "PROTOCOL://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456" +### Grouped by URL "PROTOCOL://AbC/path/file?a=1&b=2#h" #### Protocol "ipfs:" -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "chrome" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "firefox" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "electron-main" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-chrome" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-firefox" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | +| environment | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `node` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `firefox` | `ipfs://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipfs://abc/path/file?a=1&b=2#h` | +| `electron-main` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `webworker-chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `webworker-firefox` | `ipfs://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipfs://abc/path/file?a=1&b=2#h` | #### Protocol "ipns:" -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "chrome" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "firefox" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "electron-main" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-chrome" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-firefox" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | +| environment | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `node` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `firefox` | `ipns://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipns://abc/path/file?a=1&b=2#h` | +| `electron-main` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `webworker-chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `webworker-firefox` | `ipns://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipns://abc/path/file?a=1&b=2#h` | #### Protocol "http:" -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "chrome" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "firefox" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webkit" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "electron-main" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-chrome" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-firefox" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-webkit" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | +| environment | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `node` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `chrome` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `firefox` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `electron-main` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `webworker-chrome` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `webworker-firefox` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | #### Protocol "https:" -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "chrome" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "firefox" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webkit" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "electron-main" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-chrome" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-firefox" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-webkit" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | +| environment | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `node` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `chrome` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `firefox` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `electron-main` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `webworker-chrome` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `webworker-firefox` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | #### Protocol "ftp:" -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "chrome" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "firefox" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webkit" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "electron-main" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-chrome" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-firefox" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "webworker-webkit" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | - -### Grouped by environment "webworker-webkit" - -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| environment | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `node` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `chrome` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `firefox` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `electron-main` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `webworker-chrome` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `webworker-firefox` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "webworker-firefox" -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ipns:" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `ipfs://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipfs://abc/path/file?a=1&b=2#h` | +| `ipns:` | `ipns://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipns://abc/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "webworker-chrome" -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "null" | "" | "" | undefined | "" | "" | -| "ipns:" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "null" | "" | "" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | - -### Grouped by environment "webkit" - -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `ipns:` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "node" -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `ipns:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "firefox" -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ipns:" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `ipfs://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipfs://abc/path/file?a=1&b=2#h` | +| `ipns:` | `ipns://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipns://abc/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "electron-main" -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `ipns:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "chrome" -| protocol | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "ipfs:" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipfs:" | "null" | "" | "" | undefined | "" | "" | -| "ipns:" | "null" | "" | "" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ipns:" | "null" | "" | "" | undefined | "" | "" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "http:" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "https:" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "?myQueryK1=123&myQueryK2=456" | "#myHashValue1=123&myHashValue2=456" | -| "ftp:" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | - -### Grouped by URL "PROTOCOL://bafyFoo" - -#### Protocol "ipfs:" - -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "chrome" | "null" | "" | "" | undefined | "" | "" | -| "firefox" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "electron-main" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "webworker-chrome" | "null" | "" | "" | undefined | "" | "" | -| "webworker-firefox" | "ipfs://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | - -#### Protocol "ipns:" - -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "chrome" | "null" | "" | "" | undefined | "" | "" | -| "firefox" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "electron-main" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | -| "webworker-chrome" | "null" | "" | "" | undefined | "" | "" | -| "webworker-firefox" | "ipns://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-webkit" | "null" | "bafyFoo" | "bafyFoo" | undefined | "" | "" | - -#### Protocol "http:" - -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "chrome" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "firefox" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webkit" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "electron-main" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-chrome" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-firefox" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-webkit" | "http://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | - -#### Protocol "https:" - -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "chrome" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "firefox" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webkit" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "electron-main" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-chrome" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-firefox" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-webkit" | "https://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | - -#### Protocol "ftp:" - -| environment | origin | host | hostname | path | search | hash | -| --- | --- | --- | --- | --- | --- | --- | -| "node" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "chrome" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "firefox" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webkit" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "electron-main" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-chrome" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-firefox" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | -| "webworker-webkit" | "ftp://bafyfoo" | "bafyfoo" | "bafyfoo" | undefined | "" | "" | +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `ipns:` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | diff --git a/bin/update-readme.js b/bin/update-readme.js index b9c5a8e..9d5ebec 100755 --- a/bin/update-readme.js +++ b/bin/update-readme.js @@ -109,7 +109,7 @@ async function main () { ] // add tables grouped by urlTemplate - const columns = ['environment', 'protocol', 'origin', 'host', 'hostname', 'path', 'search', 'hash'] + const columns = ['environment', 'protocol', 'origin', 'host', 'hostname', 'path', 'search', 'hash', 'toString'] // eslint-disable-next-line guard-for-in for (const [groupName, groupItems] of Object.entries(groups)) { if (groupName.includes('PROTOCOL')) { diff --git a/package.json b/package.json index 1226e9d..dd3fb3c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "build": "aegir build", - "clean": "aegir clean", + "clean": "aegir clean && rm -f url-results-*.*", "lint": "aegir lint", "test": "run-s test:*", "update-results": "run-s test && node ./bin/update-readme.js", diff --git a/src/create-table-results.ts b/src/create-table-results.ts index 487473e..00006b9 100644 --- a/src/create-table-results.ts +++ b/src/create-table-results.ts @@ -2,11 +2,12 @@ export function valueNormalize (value: any): string | null { if (value === undefined) { return 'undefined' } else if (typeof value === 'object' && value === null) { - return null - } else if (typeof value === 'string') { - return `"${value}"` + return 'null' } - return `${value}` + if (value !== "") { + return `\u0060${value}\u0060` + } + return `"${value}"` } export interface TableRow { @@ -23,6 +24,7 @@ export interface TableRow { * mostly for matching against other rows for matching URLS */ urlTemplate: string + toString: string } export type TableResults = TableRow[] @@ -42,6 +44,7 @@ export function createTableResults (urlTemplate: string, environment: string): T const newUrlString = urlTemplate.replace(/^PROTOCOL:\/\//, `${protocol}://`) const urlObj = new URL(urlTemplate.replace(/^PROTOCOL:\/\//, `${protocol}://`)) const row: TableRow = { + toString: urlObj.toString(), environment, urlTemplate, url: newUrlString, @@ -65,8 +68,8 @@ export function createMarkdownTableResults (urlTemplate: string, environment: st const markdownTableLines = existingTable?.split('\n') ?? [ '', `### Environment: ${environment}`, - '| URL | origin | protocol | host | hostname | path | search | hash |', - '|------------------|--------|----------|------|----------|----------|--------|------|' + '| URL | origin | protocol | host | hostname | path | search | hash | toString |', + '|------------------|--------|----------|------|----------|----------|--------|------|----------|' ] for (const protocol of ALL_PROTOCOLS) { @@ -80,7 +83,8 @@ export function createMarkdownTableResults (urlTemplate: string, environment: st urlObj.hostname, urlObj.pathname, urlObj.search, - urlObj.hash + urlObj.hash, + urlObj.toString ] markdownTableLines.push(`| ${row.map(valueNormalize).join(' | ')} |`) diff --git a/test/urls.spec.js b/test/urls.spec.js index 52f187f..539f2cd 100644 --- a/test/urls.spec.js +++ b/test/urls.spec.js @@ -26,18 +26,18 @@ describe('URL-test', () => { const RUNNER_ENV = process.env.RUNNER_ENV if (!RUNNER_ENV) throw new Error('No RUNNER_ENV set') describe('ipfs:// URLs', () => { - let urlString = getUrlString('ipfs', 'bafyFoo') - it(`parses ipfs://bafyFoo in ${RUNNER_ENV}`, () => { - const urlString = getUrlString('ipfs', 'bafyFoo') + let urlString = getUrlString('ipfs', 'AbC') + it(`parses ipfs://AbC in ${RUNNER_ENV}`, () => { + const urlString = getUrlString('ipfs', 'AbC') const url = new URL(urlString) if (['node', 'electron-main', 'webkit', 'webworker-webkit'].includes(RUNNER_ENV)) { validateObjects(url, { origin: null, protocol: 'ipfs:', - host: 'bafyFoo', + host: 'AbC', port: '', - hostname: 'bafyFoo', + hostname: 'AbC', hash: '', search: '', query: undefined, @@ -54,38 +54,38 @@ describe('URL-test', () => { hash: '', search: '', query: undefined, - pathname: '//bafyFoo', + pathname: '//AbC', href: urlString }) } else if (RUNNER_ENV.includes('firefox')) { validateObjects(url, { - origin: 'ipfs://bafyfoo', + origin: 'ipfs://abc', protocol: 'ipfs:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', + hostname: 'abc', hash: '', search: '', query: undefined, pathname: '/', - href: urlString.replace('bafyFoo', 'bafyfoo') + '/' + href: urlString.replace('AbC', 'abc') + '/' }) } }) - it(`parses ipfs://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456 in ${RUNNER_ENV}`, () => { - urlString = getUrlString('ipfs', 'bafyFoo', '/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456') + it(`parses ipfs://AbC/path/file?a=1&b=2#h in ${RUNNER_ENV}`, () => { + urlString = getUrlString('ipfs', 'AbC', '/path/file?a=1&b=2#h') const url = new URL(urlString) if (['node', 'electron-main', 'webkit', 'webworker-webkit'].includes(RUNNER_ENV)) { validateObjects(url, { origin: null, protocol: 'ipfs:', - host: 'bafyFoo', + host: 'AbC', port: '', - hostname: 'bafyFoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'AbC', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', href: urlString @@ -97,31 +97,31 @@ describe('URL-test', () => { host: '', port: '', hostname: '', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hash: '#h', + search: '?a=1&b=2', query: undefined, - pathname: '//bafyFoo/path/file', + pathname: '//AbC/path/file', href: urlString }) } else if (RUNNER_ENV.includes('firefox')) { validateObjects(url, { - origin: 'ipfs://bafyfoo', + origin: 'ipfs://abc', protocol: 'ipfs:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'abc', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', - href: urlString.replace('bafyFoo', 'bafyfoo') + href: urlString.replace('AbC', 'abc') }) } }) }) describe('ipns:// URLs', () => { const protocol = 'ipns' - let urlString = getUrlString(protocol, 'bafyFoo') + let urlString = getUrlString(protocol, 'AbC') it(`parses ${urlString} in ${RUNNER_ENV}`, () => { const url = new URL(urlString) @@ -129,9 +129,9 @@ describe('URL-test', () => { validateObjects(url, { origin: null, protocol: 'ipns:', - host: 'bafyFoo', + host: 'AbC', port: '', - hostname: 'bafyFoo', + hostname: 'AbC', hash: '', search: '', query: undefined, @@ -148,38 +148,38 @@ describe('URL-test', () => { hash: '', search: '', query: undefined, - pathname: '//bafyFoo', + pathname: '//AbC', href: urlString }) } else if (RUNNER_ENV.includes('firefox')) { validateObjects(url, { - origin: 'ipns://bafyfoo', + origin: 'ipns://abc', protocol: 'ipns:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', + hostname: 'abc', hash: '', search: '', query: undefined, pathname: '/', - href: urlString.replace('bafyFoo', 'bafyfoo') + '/' + href: urlString.replace('AbC', 'abc') + '/' }) } }) - it(`parses ipns://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456 in ${RUNNER_ENV}`, () => { - urlString = getUrlString('ipns', 'bafyFoo', '/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456') + it(`parses ipns://AbC/path/file?a=1&b=2#h in ${RUNNER_ENV}`, () => { + urlString = getUrlString('ipns', 'AbC', '/path/file?a=1&b=2#h') const url = new URL(urlString) if (['node', 'electron-main', 'webkit', 'webworker-webkit'].includes(RUNNER_ENV)) { validateObjects(url, { origin: null, protocol: 'ipns:', - host: 'bafyFoo', + host: 'AbC', port: '', - hostname: 'bafyFoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'AbC', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', href: urlString @@ -191,24 +191,24 @@ describe('URL-test', () => { host: '', port: '', hostname: '', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hash: '#h', + search: '?a=1&b=2', query: undefined, - pathname: '//bafyFoo/path/file', + pathname: '//AbC/path/file', href: urlString }) } else if (RUNNER_ENV.includes('firefox')) { validateObjects(url, { - origin: 'ipns://bafyfoo', + origin: 'ipns://abc', protocol: 'ipns:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'abc', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', - href: urlString.replace('bafyFoo', 'bafyfoo') + href: urlString.replace('AbC', 'abc') }) } }) @@ -216,119 +216,118 @@ describe('URL-test', () => { describe('http:// URLs', () => { const protocol = 'http' - let urlString = getUrlString(protocol, 'bafyFoo') + let urlString = getUrlString(protocol, 'AbC') it(`parses ${urlString} URLs work in ${RUNNER_ENV}`, () => { const url = new URL(urlString) validateObjects(url, { - origin: 'http://bafyfoo', + origin: 'http://abc', protocol: 'http:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', + hostname: 'abc', hash: '', search: '', query: undefined, pathname: '/', - href: urlString.replace('bafyFoo', 'bafyfoo') + '/' + href: urlString.replace('AbC', 'abc') + '/' }) }) - it(`parses http://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456 in ${RUNNER_ENV}`, () => { - urlString = getUrlString('http', 'bafyFoo', '/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456') + it(`parses http://AbC/path/file?a=1&b=2#h in ${RUNNER_ENV}`, () => { + urlString = getUrlString('http', 'AbC', '/path/file?a=1&b=2#h') const url = new URL(urlString) validateObjects(url, { - origin: 'http://bafyfoo', + origin: 'http://abc', protocol: 'http:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'abc', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', - href: urlString.replace('bafyFoo', 'bafyfoo') + href: urlString.replace('AbC', 'abc') }) }) }) describe('https:// URLs', () => { const protocol = 'https' - let urlString = getUrlString(protocol, 'bafyFoo') + let urlString = getUrlString(protocol, 'AbC') it(`parses ${urlString} in ${RUNNER_ENV}`, () => { const url = new URL(urlString) validateObjects(url, { - origin: 'https://bafyfoo', + origin: 'https://abc', protocol: 'https:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', + hostname: 'abc', hash: '', search: '', query: undefined, pathname: '/', - href: urlString.replace('bafyFoo', 'bafyfoo') + '/' + href: urlString.replace('AbC', 'abc') + '/' }) }) - it(`parses https://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456 in ${RUNNER_ENV}`, () => { - urlString = getUrlString('https', 'bafyFoo', '/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456') + it(`parses https://AbC/path/file?a=1&b=2#h in ${RUNNER_ENV}`, () => { + urlString = getUrlString('https', 'AbC', '/path/file?a=1&b=2#h') const url = new URL(urlString) validateObjects(url, { - origin: 'https://bafyfoo', + origin: 'https://abc', protocol: 'https:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'abc', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', - href: urlString.replace('bafyFoo', 'bafyfoo') + href: urlString.replace('AbC', 'abc') }) }) }) describe('ftp:// URLs', () => { const protocol = 'ftp' - let urlString = getUrlString(protocol, 'bafyFoo') + let urlString = getUrlString(protocol, 'AbC') it(`parses ${urlString} in ${RUNNER_ENV}`, () => { const url = new URL(urlString) validateObjects(url, { - origin: 'ftp://bafyfoo', + origin: 'ftp://abc', protocol: 'ftp:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', + hostname: 'abc', hash: '', search: '', query: undefined, pathname: '/', - href: urlString.replace('bafyFoo', 'bafyfoo') + '/' + href: urlString.replace('AbC', 'abc') + '/' }) }) - it(`parses ftp://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456 in ${RUNNER_ENV}`, () => { - urlString = getUrlString('ftp', 'bafyFoo', '/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456') + it(`parses ftp://AbC/path/file?a=1&b=2#h in ${RUNNER_ENV}`, () => { + urlString = getUrlString('ftp', 'AbC', '/path/file?a=1&b=2#h') const url = new URL(urlString) validateObjects(url, { - origin: 'ftp://bafyfoo', + origin: 'ftp://abc', protocol: 'ftp:', - host: 'bafyfoo', + host: 'abc', port: '', - hostname: 'bafyfoo', - hash: '#myHashValue1=123&myHashValue2=456', - search: '?myQueryK1=123&myQueryK2=456', + hostname: 'abc', + hash: '#h', + search: '?a=1&b=2', query: undefined, pathname: '/path/file', - href: urlString.replace('bafyFoo', 'bafyfoo') + href: urlString.replace('AbC', 'abc') }) }) }) it('writes results to markdown files', async () => { expect(true).to.be.true() const URLS = [ - 'PROTOCOL://bafyFoo', - 'PROTOCOL://bafyFoo/path/file?myQueryK1=123&myQueryK2=456#myHashValue1=123&myHashValue2=456' + 'PROTOCOL://AbC/path/file?a=1&b=2#h' ] for (const url of URLS) { const table = createTableResults(url, RUNNER_ENV) From dadf069d7134464e6ef57bde5c5d448f8a23f8ff Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:00:44 -0700 Subject: [PATCH 2/2] docs: update README with webworker and webkit --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index e8ee896..87ea294 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,11 @@ The following tables are generated from the test suite. | `node` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | | `chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | | `firefox` | `ipfs://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipfs://abc/path/file?a=1&b=2#h` | +| `webkit` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | | `electron-main` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | | `webworker-chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | | `webworker-firefox` | `ipfs://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipfs://abc/path/file?a=1&b=2#h` | +| `webworker-webkit` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | #### Protocol "ipns:" @@ -38,9 +40,11 @@ The following tables are generated from the test suite. | `node` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | | `chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | | `firefox` | `ipns://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipns://abc/path/file?a=1&b=2#h` | +| `webkit` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | | `electron-main` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | | `webworker-chrome` | `null` | "" | "" | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | | `webworker-firefox` | `ipns://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ipns://abc/path/file?a=1&b=2#h` | +| `webworker-webkit` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | #### Protocol "http:" @@ -49,9 +53,11 @@ The following tables are generated from the test suite. | `node` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | | `chrome` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | | `firefox` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `webkit` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | | `electron-main` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | | `webworker-chrome` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | | `webworker-firefox` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `webworker-webkit` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | #### Protocol "https:" @@ -60,9 +66,11 @@ The following tables are generated from the test suite. | `node` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | | `chrome` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | | `firefox` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `webkit` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | | `electron-main` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | | `webworker-chrome` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | | `webworker-firefox` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `webworker-webkit` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | #### Protocol "ftp:" @@ -71,9 +79,21 @@ The following tables are generated from the test suite. | `node` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | | `chrome` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | | `firefox` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `webkit` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | | `electron-main` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | | `webworker-chrome` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | | `webworker-firefox` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +| `webworker-webkit` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | + +### Grouped by environment "webworker-webkit" + +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `ipns:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | ### Grouped by environment "webworker-firefox" @@ -95,6 +115,16 @@ The following tables are generated from the test suite. | `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | | `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | +### Grouped by environment "webkit" + +| protocol | origin | host | hostname | path | search | hash | toString | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `ipfs:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipfs://AbC/path/file?a=1&b=2#h` | +| `ipns:` | `null` | `AbC` | `AbC` | undefined | `?a=1&b=2` | `#h` | `ipns://AbC/path/file?a=1&b=2#h` | +| `http:` | `http://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `http://abc/path/file?a=1&b=2#h` | +| `https:` | `https://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `https://abc/path/file?a=1&b=2#h` | +| `ftp:` | `ftp://abc` | `abc` | `abc` | undefined | `?a=1&b=2` | `#h` | `ftp://abc/path/file?a=1&b=2#h` | + ### Grouped by environment "node" | protocol | origin | host | hostname | path | search | hash | toString |