@tonyclaw/llm-inspector 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +17 -0
- package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
- package/.output/public/assets/index-B3RwBPLW.css +1 -0
- package/.output/public/assets/index-s4lwsWvq.js +97 -0
- package/.output/public/assets/main-Cp8AM0Pa.js +17 -0
- package/.output/public/assets/minimax-BPMzvuL-.jpeg +0 -0
- package/.output/public/assets/qwen-CONDcHqt.png +0 -0
- package/.output/public/assets/zhipuai-BPNAnxo-.svg +219 -0
- package/.output/server/_chunks/ssr-renderer.mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
- package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
- package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +34 -0
- package/.output/server/_libs/ajv-formats.mjs +330 -0
- package/.output/server/_libs/ajv.mjs +11444 -0
- package/.output/server/_libs/aria-hidden.mjs +122 -0
- package/.output/server/_libs/atomically.mjs +152 -0
- package/.output/server/_libs/bail.mjs +8 -0
- package/.output/server/_libs/character-entities.mjs +2130 -0
- package/.output/server/_libs/class-variance-authority.mjs +44 -0
- package/.output/server/_libs/clsx.mjs +16 -0
- package/.output/server/_libs/comma-separated-tokens.mjs +10 -0
- package/.output/server/_libs/conf.mjs +635 -0
- package/.output/server/_libs/cookie-es.mjs +58 -0
- package/.output/server/_libs/core-util-is.mjs +75 -0
- package/.output/server/_libs/croner.mjs +1 -0
- package/.output/server/_libs/crossws.mjs +1 -0
- package/.output/server/_libs/debounce-fn.mjs +69 -0
- package/.output/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/.output/server/_libs/detect-node-es.mjs +1 -0
- package/.output/server/_libs/devlop.mjs +8 -0
- package/.output/server/_libs/dot-prop.mjs +265 -0
- package/.output/server/_libs/env-paths.mjs +57 -0
- package/.output/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/.output/server/_libs/extend.mjs +97 -0
- package/.output/server/_libs/fast-deep-equal.mjs +38 -0
- package/.output/server/_libs/fast-uri.mjs +812 -0
- package/.output/server/_libs/floating-ui__core.mjs +725 -0
- package/.output/server/_libs/floating-ui__dom.mjs +622 -0
- package/.output/server/_libs/floating-ui__react-dom.mjs +292 -0
- package/.output/server/_libs/floating-ui__utils.mjs +320 -0
- package/.output/server/_libs/get-nonce.mjs +9 -0
- package/.output/server/_libs/h3-v2.mjs +276 -0
- package/.output/server/_libs/h3.mjs +400 -0
- package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/.output/server/_libs/hast-util-whitespace.mjs +10 -0
- package/.output/server/_libs/hookable.mjs +1 -0
- package/.output/server/_libs/html-url-attributes.mjs +26 -0
- package/.output/server/_libs/immediate.mjs +74 -0
- package/.output/server/_libs/inherits.mjs +50 -0
- package/.output/server/_libs/inline-style-parser.mjs +142 -0
- package/.output/server/_libs/is-plain-obj.mjs +10 -0
- package/.output/server/_libs/isarray.mjs +14 -0
- package/.output/server/_libs/isbot.mjs +20 -0
- package/.output/server/_libs/json-schema-traverse.mjs +180 -0
- package/.output/server/_libs/jszip.mjs +3049 -0
- package/.output/server/_libs/lie.mjs +273 -0
- package/.output/server/_libs/lucide-react.mjs +368 -0
- package/.output/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/.output/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/.output/server/_libs/mdast-util-to-string.mjs +38 -0
- package/.output/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/.output/server/_libs/micromark-factory-destination.mjs +94 -0
- package/.output/server/_libs/micromark-factory-label.mjs +63 -0
- package/.output/server/_libs/micromark-factory-space.mjs +24 -0
- package/.output/server/_libs/micromark-factory-title.mjs +65 -0
- package/.output/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/.output/server/_libs/micromark-util-character.mjs +44 -0
- package/.output/server/_libs/micromark-util-chunked.mjs +36 -0
- package/.output/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/.output/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/.output/server/_libs/micromark-util-encode.mjs +1 -0
- package/.output/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/.output/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/.output/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/.output/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/.output/server/_libs/micromark.mjs +906 -0
- package/.output/server/_libs/mimic-function.mjs +47 -0
- package/.output/server/_libs/ohash.mjs +1 -0
- package/.output/server/_libs/pako.mjs +4223 -0
- package/.output/server/_libs/process-nextick-args.mjs +48 -0
- package/.output/server/_libs/property-information.mjs +1209 -0
- package/.output/server/_libs/radix-ui.mjs +1 -0
- package/.output/server/_libs/radix-ui__number.mjs +6 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
- package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
- package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +144 -0
- package/.output/server/_libs/radix-ui__react-collection.mjs +69 -0
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
- package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
- package/.output/server/_libs/radix-ui__react-dialog.mjs +325 -0
- package/.output/server/_libs/radix-ui__react-direction.mjs +9 -0
- package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
- package/.output/server/_libs/radix-ui__react-form.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-label.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popover.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popper.mjs +286 -0
- package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
- package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
- package/.output/server/_libs/radix-ui__react-primitive.mjs +42 -0
- package/.output/server/_libs/radix-ui__react-progress.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +224 -0
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +721 -0
- package/.output/server/_libs/radix-ui__react-select.mjs +1163 -0
- package/.output/server/_libs/radix-ui__react-separator.mjs +28 -0
- package/.output/server/_libs/radix-ui__react-slider.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-slot.mjs +99 -0
- package/.output/server/_libs/radix-ui__react-switch.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tabs.mjs +189 -0
- package/.output/server/_libs/radix-ui__react-toast.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +495 -0
- package/.output/server/_libs/radix-ui__react-use-previous.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-use-size.mjs +39 -0
- package/.output/server/_libs/react-dom.mjs +9935 -0
- package/.output/server/_libs/react-markdown.mjs +147 -0
- package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
- package/.output/server/_libs/react-remove-scroll.mjs +328 -0
- package/.output/server/_libs/react-style-singleton.mjs +69 -0
- package/.output/server/_libs/react.mjs +515 -0
- package/.output/server/_libs/readable-stream.mjs +1518 -0
- package/.output/server/_libs/remark-parse.mjs +19 -0
- package/.output/server/_libs/remark-rehype.mjs +21 -0
- package/.output/server/_libs/rou3.mjs +8 -0
- package/.output/server/_libs/safe-buffer.mjs +64 -0
- package/.output/server/_libs/semver.mjs +1984 -0
- package/.output/server/_libs/seroval-plugins.mjs +58 -0
- package/.output/server/_libs/seroval.mjs +1765 -0
- package/.output/server/_libs/setimmediate.mjs +1 -0
- package/.output/server/_libs/space-separated-tokens.mjs +6 -0
- package/.output/server/_libs/srvx.mjs +334 -0
- package/.output/server/_libs/stubborn-fs.mjs +91 -0
- package/.output/server/_libs/stubborn-utils.mjs +66 -0
- package/.output/server/_libs/style-to-js.mjs +72 -0
- package/.output/server/_libs/style-to-object.mjs +38 -0
- package/.output/server/_libs/tailwind-merge.mjs +3010 -0
- package/.output/server/_libs/tanstack__history.mjs +217 -0
- package/.output/server/_libs/tanstack__react-router.mjs +1480 -0
- package/.output/server/_libs/tanstack__react-store.mjs +1 -0
- package/.output/server/_libs/tanstack__react-virtual.mjs +44 -0
- package/.output/server/_libs/tanstack__router-core.mjs +4827 -0
- package/.output/server/_libs/tanstack__store.mjs +1 -0
- package/.output/server/_libs/tanstack__virtual-core.mjs +1225 -0
- package/.output/server/_libs/tiny-invariant.mjs +12 -0
- package/.output/server/_libs/tiny-warning.mjs +5 -0
- package/.output/server/_libs/trim-lines.mjs +41 -0
- package/.output/server/_libs/trough.mjs +85 -0
- package/.output/server/_libs/tslib.mjs +576 -0
- package/.output/server/_libs/ufo.mjs +54 -0
- package/.output/server/_libs/uint8array-extras.mjs +69 -0
- package/.output/server/_libs/unctx.mjs +1 -0
- package/.output/server/_libs/ungap__structured-clone.mjs +212 -0
- package/.output/server/_libs/unified.mjs +661 -0
- package/.output/server/_libs/unist-util-is.mjs +100 -0
- package/.output/server/_libs/unist-util-position.mjs +27 -0
- package/.output/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/.output/server/_libs/unist-util-visit-parents.mjs +82 -0
- package/.output/server/_libs/unist-util-visit.mjs +24 -0
- package/.output/server/_libs/unstorage.mjs +1 -0
- package/.output/server/_libs/use-callback-ref.mjs +66 -0
- package/.output/server/_libs/use-sidecar.mjs +106 -0
- package/.output/server/_libs/use-sync-external-store.mjs +1 -0
- package/.output/server/_libs/util-deprecate.mjs +12 -0
- package/.output/server/_libs/vfile-message.mjs +138 -0
- package/.output/server/_libs/vfile.mjs +467 -0
- package/.output/server/_libs/when-exit.mjs +53 -0
- package/.output/server/_libs/zod.mjs +4460 -0
- package/.output/server/_ssr/index-ByCLZu7J.mjs +3061 -0
- package/.output/server/_ssr/index.mjs +1176 -0
- package/.output/server/_ssr/router-Bq_mxeNz.mjs +2872 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-C4E0e9my.mjs +4 -0
- package/.output/server/index.mjs +393 -0
- package/README.md +196 -0
- package/package.json +91 -0
- package/src/assets/logos/alibaba.svg +1 -0
- package/src/assets/logos/anthropic.svg +1 -0
- package/src/assets/logos/deepseek.svg +1 -0
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +1 -0
- package/src/assets/logos/qwen.png +0 -0
- package/src/assets/logos/zhipuai.svg +219 -0
- package/src/cli.ts +68 -0
- package/src/components/ProxyViewer.tsx +325 -0
- package/src/components/ProxyViewerContainer.tsx +211 -0
- package/src/components/providers/ProviderCard.tsx +186 -0
- package/src/components/providers/ProviderForm.tsx +259 -0
- package/src/components/providers/ProviderLogo.tsx +111 -0
- package/src/components/providers/ProvidersPanel.tsx +259 -0
- package/src/components/providers/SettingsDialog.tsx +39 -0
- package/src/components/proxy-viewer/ConversationGroup.tsx +68 -0
- package/src/components/proxy-viewer/ConversationHeader.tsx +141 -0
- package/src/components/proxy-viewer/LogEntry.tsx +225 -0
- package/src/components/proxy-viewer/LogEntryHeader.tsx +250 -0
- package/src/components/proxy-viewer/ReplayDialog.tsx +208 -0
- package/src/components/proxy-viewer/ResponseView.tsx +161 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +171 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +139 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +64 -0
- package/src/components/proxy-viewer/formats/index.tsx +24 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +80 -0
- package/src/components/proxy-viewer/index.ts +8 -0
- package/src/components/ui/badge.tsx +47 -0
- package/src/components/ui/button.tsx +47 -0
- package/src/components/ui/collapsible.tsx +21 -0
- package/src/components/ui/dialog.tsx +129 -0
- package/src/components/ui/json-viewer.tsx +464 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/select.tsx +178 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/tabs.tsx +88 -0
- package/src/components/ui/tooltip.tsx +51 -0
- package/src/index.css +11 -0
- package/src/lib/export-logs.ts +51 -0
- package/src/lib/utils.ts +22 -0
- package/src/proxy/chunkStorage.ts +118 -0
- package/src/proxy/constants.ts +36 -0
- package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
- package/src/proxy/formats/anthropic/handler.ts +74 -0
- package/src/proxy/formats/anthropic/index.ts +14 -0
- package/src/proxy/formats/anthropic/register.ts +4 -0
- package/src/proxy/formats/anthropic/schemas.ts +217 -0
- package/src/proxy/formats/anthropic/stream.ts +167 -0
- package/src/proxy/formats/handler.ts +46 -0
- package/src/proxy/formats/index.ts +12 -0
- package/src/proxy/formats/jsonSchema.ts +24 -0
- package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
- package/src/proxy/formats/openai/handler.ts +70 -0
- package/src/proxy/formats/openai/index.ts +25 -0
- package/src/proxy/formats/openai/provider.ts +50 -0
- package/src/proxy/formats/openai/register.ts +4 -0
- package/src/proxy/formats/openai/schemas.ts +150 -0
- package/src/proxy/formats/openai/stream.ts +153 -0
- package/src/proxy/formats/protocol.ts +50 -0
- package/src/proxy/formats/providerRegistry.ts +51 -0
- package/src/proxy/formats/providers/index.ts +3 -0
- package/src/proxy/formats/registry.ts +61 -0
- package/src/proxy/handler.ts +389 -0
- package/src/proxy/logIndex.ts +187 -0
- package/src/proxy/logger.ts +99 -0
- package/src/proxy/providers.ts +234 -0
- package/src/proxy/schemas.ts +160 -0
- package/src/proxy/socketTracker.ts +158 -0
- package/src/proxy/store.ts +386 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +38 -0
- package/src/routes/api/config.paths.ts +14 -0
- package/src/routes/api/health.ts +11 -0
- package/src/routes/api/logs.$id.chunks.ts +36 -0
- package/src/routes/api/logs.$id.replay.ts +262 -0
- package/src/routes/api/logs.$id.ts +22 -0
- package/src/routes/api/logs.stream.ts +64 -0
- package/src/routes/api/logs.ts +30 -0
- package/src/routes/api/models.ts +10 -0
- package/src/routes/api/providers.$providerId.ts +45 -0
- package/src/routes/api/providers.ts +37 -0
- package/src/routes/api/sessions.ts +10 -0
- package/src/routes/index.tsx +6 -0
- package/src/routes/proxy/$.ts +15 -0
- package/styles/globals.css +121 -0
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
var fastUri = { exports: {} };
|
|
2
|
+
var utils;
|
|
3
|
+
var hasRequiredUtils;
|
|
4
|
+
function requireUtils() {
|
|
5
|
+
if (hasRequiredUtils) return utils;
|
|
6
|
+
hasRequiredUtils = 1;
|
|
7
|
+
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
8
|
+
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
9
|
+
const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
10
|
+
const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
11
|
+
const isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
|
|
12
|
+
function stringArrayToHexStripped(input) {
|
|
13
|
+
let acc = "";
|
|
14
|
+
let code = 0;
|
|
15
|
+
let i = 0;
|
|
16
|
+
for (i = 0; i < input.length; i++) {
|
|
17
|
+
code = input[i].charCodeAt(0);
|
|
18
|
+
if (code === 48) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
acc += input[i];
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
for (i += 1; i < input.length; i++) {
|
|
28
|
+
code = input[i].charCodeAt(0);
|
|
29
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
acc += input[i];
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}
|
|
36
|
+
const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
|
|
37
|
+
function consumeIsZone(buffer) {
|
|
38
|
+
buffer.length = 0;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
function consumeHextets(buffer, address, output) {
|
|
42
|
+
if (buffer.length) {
|
|
43
|
+
const hex = stringArrayToHexStripped(buffer);
|
|
44
|
+
if (hex !== "") {
|
|
45
|
+
address.push(hex);
|
|
46
|
+
} else {
|
|
47
|
+
output.error = true;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
buffer.length = 0;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
function getIPV6(input) {
|
|
55
|
+
let tokenCount = 0;
|
|
56
|
+
const output = { error: false, address: "", zone: "" };
|
|
57
|
+
const address = [];
|
|
58
|
+
const buffer = [];
|
|
59
|
+
let endipv6Encountered = false;
|
|
60
|
+
let endIpv6 = false;
|
|
61
|
+
let consume = consumeHextets;
|
|
62
|
+
for (let i = 0; i < input.length; i++) {
|
|
63
|
+
const cursor = input[i];
|
|
64
|
+
if (cursor === "[" || cursor === "]") {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (cursor === ":") {
|
|
68
|
+
if (endipv6Encountered === true) {
|
|
69
|
+
endIpv6 = true;
|
|
70
|
+
}
|
|
71
|
+
if (!consume(buffer, address, output)) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
if (++tokenCount > 7) {
|
|
75
|
+
output.error = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
if (i > 0 && input[i - 1] === ":") {
|
|
79
|
+
endipv6Encountered = true;
|
|
80
|
+
}
|
|
81
|
+
address.push(":");
|
|
82
|
+
continue;
|
|
83
|
+
} else if (cursor === "%") {
|
|
84
|
+
if (!consume(buffer, address, output)) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
consume = consumeIsZone;
|
|
88
|
+
} else {
|
|
89
|
+
buffer.push(cursor);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (buffer.length) {
|
|
94
|
+
if (consume === consumeIsZone) {
|
|
95
|
+
output.zone = buffer.join("");
|
|
96
|
+
} else if (endIpv6) {
|
|
97
|
+
address.push(buffer.join(""));
|
|
98
|
+
} else {
|
|
99
|
+
address.push(stringArrayToHexStripped(buffer));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
output.address = address.join("");
|
|
103
|
+
return output;
|
|
104
|
+
}
|
|
105
|
+
function normalizeIPv6(host) {
|
|
106
|
+
if (findToken(host, ":") < 2) {
|
|
107
|
+
return { host, isIPV6: false };
|
|
108
|
+
}
|
|
109
|
+
const ipv6 = getIPV6(host);
|
|
110
|
+
if (!ipv6.error) {
|
|
111
|
+
let newHost = ipv6.address;
|
|
112
|
+
let escapedHost = ipv6.address;
|
|
113
|
+
if (ipv6.zone) {
|
|
114
|
+
newHost += "%" + ipv6.zone;
|
|
115
|
+
escapedHost += "%25" + ipv6.zone;
|
|
116
|
+
}
|
|
117
|
+
return { host: newHost, isIPV6: true, escapedHost };
|
|
118
|
+
} else {
|
|
119
|
+
return { host, isIPV6: false };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function findToken(str, token) {
|
|
123
|
+
let ind = 0;
|
|
124
|
+
for (let i = 0; i < str.length; i++) {
|
|
125
|
+
if (str[i] === token) ind++;
|
|
126
|
+
}
|
|
127
|
+
return ind;
|
|
128
|
+
}
|
|
129
|
+
function removeDotSegments(path) {
|
|
130
|
+
let input = path;
|
|
131
|
+
const output = [];
|
|
132
|
+
let nextSlash = -1;
|
|
133
|
+
let len = 0;
|
|
134
|
+
while (len = input.length) {
|
|
135
|
+
if (len === 1) {
|
|
136
|
+
if (input === ".") {
|
|
137
|
+
break;
|
|
138
|
+
} else if (input === "/") {
|
|
139
|
+
output.push("/");
|
|
140
|
+
break;
|
|
141
|
+
} else {
|
|
142
|
+
output.push(input);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
} else if (len === 2) {
|
|
146
|
+
if (input[0] === ".") {
|
|
147
|
+
if (input[1] === ".") {
|
|
148
|
+
break;
|
|
149
|
+
} else if (input[1] === "/") {
|
|
150
|
+
input = input.slice(2);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
} else if (input[0] === "/") {
|
|
154
|
+
if (input[1] === "." || input[1] === "/") {
|
|
155
|
+
output.push("/");
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
} else if (len === 3) {
|
|
160
|
+
if (input === "/..") {
|
|
161
|
+
if (output.length !== 0) {
|
|
162
|
+
output.pop();
|
|
163
|
+
}
|
|
164
|
+
output.push("/");
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (input[0] === ".") {
|
|
169
|
+
if (input[1] === ".") {
|
|
170
|
+
if (input[2] === "/") {
|
|
171
|
+
input = input.slice(3);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
} else if (input[1] === "/") {
|
|
175
|
+
input = input.slice(2);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
} else if (input[0] === "/") {
|
|
179
|
+
if (input[1] === ".") {
|
|
180
|
+
if (input[2] === "/") {
|
|
181
|
+
input = input.slice(2);
|
|
182
|
+
continue;
|
|
183
|
+
} else if (input[2] === ".") {
|
|
184
|
+
if (input[3] === "/") {
|
|
185
|
+
input = input.slice(3);
|
|
186
|
+
if (output.length !== 0) {
|
|
187
|
+
output.pop();
|
|
188
|
+
}
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if ((nextSlash = input.indexOf("/", 1)) === -1) {
|
|
195
|
+
output.push(input);
|
|
196
|
+
break;
|
|
197
|
+
} else {
|
|
198
|
+
output.push(input.slice(0, nextSlash));
|
|
199
|
+
input = input.slice(nextSlash);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return output.join("");
|
|
203
|
+
}
|
|
204
|
+
const HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
205
|
+
const HOST_DELIM_RE = /[@/?#:]/g;
|
|
206
|
+
const HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
207
|
+
function reescapeHostDelimiters(host, isIP) {
|
|
208
|
+
const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
|
|
209
|
+
re.lastIndex = 0;
|
|
210
|
+
return host.replace(re, (ch) => HOST_DELIMS[ch]);
|
|
211
|
+
}
|
|
212
|
+
function normalizePercentEncoding(input, decodeUnreserved = false) {
|
|
213
|
+
if (input.indexOf("%") === -1) {
|
|
214
|
+
return input;
|
|
215
|
+
}
|
|
216
|
+
let output = "";
|
|
217
|
+
for (let i = 0; i < input.length; i++) {
|
|
218
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
219
|
+
const hex = input.slice(i + 1, i + 3);
|
|
220
|
+
if (isHexPair(hex)) {
|
|
221
|
+
const normalizedHex = hex.toUpperCase();
|
|
222
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
223
|
+
if (decodeUnreserved && isUnreserved(decoded)) {
|
|
224
|
+
output += decoded;
|
|
225
|
+
} else {
|
|
226
|
+
output += "%" + normalizedHex;
|
|
227
|
+
}
|
|
228
|
+
i += 2;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
output += input[i];
|
|
233
|
+
}
|
|
234
|
+
return output;
|
|
235
|
+
}
|
|
236
|
+
function normalizePathEncoding(input) {
|
|
237
|
+
let output = "";
|
|
238
|
+
for (let i = 0; i < input.length; i++) {
|
|
239
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
240
|
+
const hex = input.slice(i + 1, i + 3);
|
|
241
|
+
if (isHexPair(hex)) {
|
|
242
|
+
const normalizedHex = hex.toUpperCase();
|
|
243
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
244
|
+
if (decoded !== "." && isUnreserved(decoded)) {
|
|
245
|
+
output += decoded;
|
|
246
|
+
} else {
|
|
247
|
+
output += "%" + normalizedHex;
|
|
248
|
+
}
|
|
249
|
+
i += 2;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (isPathCharacter(input[i])) {
|
|
254
|
+
output += input[i];
|
|
255
|
+
} else {
|
|
256
|
+
output += escape(input[i]);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return output;
|
|
260
|
+
}
|
|
261
|
+
function escapePreservingEscapes(input) {
|
|
262
|
+
let output = "";
|
|
263
|
+
for (let i = 0; i < input.length; i++) {
|
|
264
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
265
|
+
const hex = input.slice(i + 1, i + 3);
|
|
266
|
+
if (isHexPair(hex)) {
|
|
267
|
+
output += "%" + hex.toUpperCase();
|
|
268
|
+
i += 2;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
output += escape(input[i]);
|
|
273
|
+
}
|
|
274
|
+
return output;
|
|
275
|
+
}
|
|
276
|
+
function recomposeAuthority(component) {
|
|
277
|
+
const uriTokens = [];
|
|
278
|
+
if (component.userinfo !== void 0) {
|
|
279
|
+
uriTokens.push(component.userinfo);
|
|
280
|
+
uriTokens.push("@");
|
|
281
|
+
}
|
|
282
|
+
if (component.host !== void 0) {
|
|
283
|
+
let host = unescape(component.host);
|
|
284
|
+
if (!isIPv4(host)) {
|
|
285
|
+
const ipV6res = normalizeIPv6(host);
|
|
286
|
+
if (ipV6res.isIPV6 === true) {
|
|
287
|
+
host = `[${ipV6res.escapedHost}]`;
|
|
288
|
+
} else {
|
|
289
|
+
host = reescapeHostDelimiters(host, false);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
uriTokens.push(host);
|
|
293
|
+
}
|
|
294
|
+
if (typeof component.port === "number" || typeof component.port === "string") {
|
|
295
|
+
uriTokens.push(":");
|
|
296
|
+
uriTokens.push(String(component.port));
|
|
297
|
+
}
|
|
298
|
+
return uriTokens.length ? uriTokens.join("") : void 0;
|
|
299
|
+
}
|
|
300
|
+
utils = {
|
|
301
|
+
nonSimpleDomain,
|
|
302
|
+
recomposeAuthority,
|
|
303
|
+
reescapeHostDelimiters,
|
|
304
|
+
normalizePercentEncoding,
|
|
305
|
+
normalizePathEncoding,
|
|
306
|
+
escapePreservingEscapes,
|
|
307
|
+
removeDotSegments,
|
|
308
|
+
isIPv4,
|
|
309
|
+
isUUID,
|
|
310
|
+
normalizeIPv6,
|
|
311
|
+
stringArrayToHexStripped
|
|
312
|
+
};
|
|
313
|
+
return utils;
|
|
314
|
+
}
|
|
315
|
+
var schemes;
|
|
316
|
+
var hasRequiredSchemes;
|
|
317
|
+
function requireSchemes() {
|
|
318
|
+
if (hasRequiredSchemes) return schemes;
|
|
319
|
+
hasRequiredSchemes = 1;
|
|
320
|
+
const { isUUID } = /* @__PURE__ */ requireUtils();
|
|
321
|
+
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
322
|
+
const supportedSchemeNames = (
|
|
323
|
+
/** @type {const} */
|
|
324
|
+
[
|
|
325
|
+
"http",
|
|
326
|
+
"https",
|
|
327
|
+
"ws",
|
|
328
|
+
"wss",
|
|
329
|
+
"urn",
|
|
330
|
+
"urn:uuid"
|
|
331
|
+
]
|
|
332
|
+
);
|
|
333
|
+
function isValidSchemeName(name) {
|
|
334
|
+
return supportedSchemeNames.indexOf(
|
|
335
|
+
/** @type {*} */
|
|
336
|
+
name
|
|
337
|
+
) !== -1;
|
|
338
|
+
}
|
|
339
|
+
function wsIsSecure(wsComponent) {
|
|
340
|
+
if (wsComponent.secure === true) {
|
|
341
|
+
return true;
|
|
342
|
+
} else if (wsComponent.secure === false) {
|
|
343
|
+
return false;
|
|
344
|
+
} else if (wsComponent.scheme) {
|
|
345
|
+
return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S");
|
|
346
|
+
} else {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function httpParse(component) {
|
|
351
|
+
if (!component.host) {
|
|
352
|
+
component.error = component.error || "HTTP URIs must have a host.";
|
|
353
|
+
}
|
|
354
|
+
return component;
|
|
355
|
+
}
|
|
356
|
+
function httpSerialize(component) {
|
|
357
|
+
const secure = String(component.scheme).toLowerCase() === "https";
|
|
358
|
+
if (component.port === (secure ? 443 : 80) || component.port === "") {
|
|
359
|
+
component.port = void 0;
|
|
360
|
+
}
|
|
361
|
+
if (!component.path) {
|
|
362
|
+
component.path = "/";
|
|
363
|
+
}
|
|
364
|
+
return component;
|
|
365
|
+
}
|
|
366
|
+
function wsParse(wsComponent) {
|
|
367
|
+
wsComponent.secure = wsIsSecure(wsComponent);
|
|
368
|
+
wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : "");
|
|
369
|
+
wsComponent.path = void 0;
|
|
370
|
+
wsComponent.query = void 0;
|
|
371
|
+
return wsComponent;
|
|
372
|
+
}
|
|
373
|
+
function wsSerialize(wsComponent) {
|
|
374
|
+
if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") {
|
|
375
|
+
wsComponent.port = void 0;
|
|
376
|
+
}
|
|
377
|
+
if (typeof wsComponent.secure === "boolean") {
|
|
378
|
+
wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
|
|
379
|
+
wsComponent.secure = void 0;
|
|
380
|
+
}
|
|
381
|
+
if (wsComponent.resourceName) {
|
|
382
|
+
const [path, query] = wsComponent.resourceName.split("?");
|
|
383
|
+
wsComponent.path = path && path !== "/" ? path : void 0;
|
|
384
|
+
wsComponent.query = query;
|
|
385
|
+
wsComponent.resourceName = void 0;
|
|
386
|
+
}
|
|
387
|
+
wsComponent.fragment = void 0;
|
|
388
|
+
return wsComponent;
|
|
389
|
+
}
|
|
390
|
+
function urnParse(urnComponent, options) {
|
|
391
|
+
if (!urnComponent.path) {
|
|
392
|
+
urnComponent.error = "URN can not be parsed";
|
|
393
|
+
return urnComponent;
|
|
394
|
+
}
|
|
395
|
+
const matches = urnComponent.path.match(URN_REG);
|
|
396
|
+
if (matches) {
|
|
397
|
+
const scheme = options.scheme || urnComponent.scheme || "urn";
|
|
398
|
+
urnComponent.nid = matches[1].toLowerCase();
|
|
399
|
+
urnComponent.nss = matches[2];
|
|
400
|
+
const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
|
|
401
|
+
const schemeHandler = getSchemeHandler(urnScheme);
|
|
402
|
+
urnComponent.path = void 0;
|
|
403
|
+
if (schemeHandler) {
|
|
404
|
+
urnComponent = schemeHandler.parse(urnComponent, options);
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
urnComponent.error = urnComponent.error || "URN can not be parsed.";
|
|
408
|
+
}
|
|
409
|
+
return urnComponent;
|
|
410
|
+
}
|
|
411
|
+
function urnSerialize(urnComponent, options) {
|
|
412
|
+
if (urnComponent.nid === void 0) {
|
|
413
|
+
throw new Error("URN without nid cannot be serialized");
|
|
414
|
+
}
|
|
415
|
+
const scheme = options.scheme || urnComponent.scheme || "urn";
|
|
416
|
+
const nid = urnComponent.nid.toLowerCase();
|
|
417
|
+
const urnScheme = `${scheme}:${options.nid || nid}`;
|
|
418
|
+
const schemeHandler = getSchemeHandler(urnScheme);
|
|
419
|
+
if (schemeHandler) {
|
|
420
|
+
urnComponent = schemeHandler.serialize(urnComponent, options);
|
|
421
|
+
}
|
|
422
|
+
const uriComponent = urnComponent;
|
|
423
|
+
const nss = urnComponent.nss;
|
|
424
|
+
uriComponent.path = `${nid || options.nid}:${nss}`;
|
|
425
|
+
options.skipEscape = true;
|
|
426
|
+
return uriComponent;
|
|
427
|
+
}
|
|
428
|
+
function urnuuidParse(urnComponent, options) {
|
|
429
|
+
const uuidComponent = urnComponent;
|
|
430
|
+
uuidComponent.uuid = uuidComponent.nss;
|
|
431
|
+
uuidComponent.nss = void 0;
|
|
432
|
+
if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
|
|
433
|
+
uuidComponent.error = uuidComponent.error || "UUID is not valid.";
|
|
434
|
+
}
|
|
435
|
+
return uuidComponent;
|
|
436
|
+
}
|
|
437
|
+
function urnuuidSerialize(uuidComponent) {
|
|
438
|
+
const urnComponent = uuidComponent;
|
|
439
|
+
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
440
|
+
return urnComponent;
|
|
441
|
+
}
|
|
442
|
+
const http = (
|
|
443
|
+
/** @type {SchemeHandler} */
|
|
444
|
+
{
|
|
445
|
+
scheme: "http",
|
|
446
|
+
domainHost: true,
|
|
447
|
+
parse: httpParse,
|
|
448
|
+
serialize: httpSerialize
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
const https = (
|
|
452
|
+
/** @type {SchemeHandler} */
|
|
453
|
+
{
|
|
454
|
+
scheme: "https",
|
|
455
|
+
domainHost: http.domainHost,
|
|
456
|
+
parse: httpParse,
|
|
457
|
+
serialize: httpSerialize
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
const ws = (
|
|
461
|
+
/** @type {SchemeHandler} */
|
|
462
|
+
{
|
|
463
|
+
scheme: "ws",
|
|
464
|
+
domainHost: true,
|
|
465
|
+
parse: wsParse,
|
|
466
|
+
serialize: wsSerialize
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
const wss = (
|
|
470
|
+
/** @type {SchemeHandler} */
|
|
471
|
+
{
|
|
472
|
+
scheme: "wss",
|
|
473
|
+
domainHost: ws.domainHost,
|
|
474
|
+
parse: ws.parse,
|
|
475
|
+
serialize: ws.serialize
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
const urn = (
|
|
479
|
+
/** @type {SchemeHandler} */
|
|
480
|
+
{
|
|
481
|
+
scheme: "urn",
|
|
482
|
+
parse: urnParse,
|
|
483
|
+
serialize: urnSerialize,
|
|
484
|
+
skipNormalize: true
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
const urnuuid = (
|
|
488
|
+
/** @type {SchemeHandler} */
|
|
489
|
+
{
|
|
490
|
+
scheme: "urn:uuid",
|
|
491
|
+
parse: urnuuidParse,
|
|
492
|
+
serialize: urnuuidSerialize,
|
|
493
|
+
skipNormalize: true
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
const SCHEMES = (
|
|
497
|
+
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
498
|
+
{
|
|
499
|
+
http,
|
|
500
|
+
https,
|
|
501
|
+
ws,
|
|
502
|
+
wss,
|
|
503
|
+
urn,
|
|
504
|
+
"urn:uuid": urnuuid
|
|
505
|
+
}
|
|
506
|
+
);
|
|
507
|
+
Object.setPrototypeOf(SCHEMES, null);
|
|
508
|
+
function getSchemeHandler(scheme) {
|
|
509
|
+
return scheme && (SCHEMES[
|
|
510
|
+
/** @type {SchemeName} */
|
|
511
|
+
scheme
|
|
512
|
+
] || SCHEMES[
|
|
513
|
+
/** @type {SchemeName} */
|
|
514
|
+
scheme.toLowerCase()
|
|
515
|
+
]) || void 0;
|
|
516
|
+
}
|
|
517
|
+
schemes = {
|
|
518
|
+
wsIsSecure,
|
|
519
|
+
SCHEMES,
|
|
520
|
+
isValidSchemeName,
|
|
521
|
+
getSchemeHandler
|
|
522
|
+
};
|
|
523
|
+
return schemes;
|
|
524
|
+
}
|
|
525
|
+
var hasRequiredFastUri;
|
|
526
|
+
function requireFastUri() {
|
|
527
|
+
if (hasRequiredFastUri) return fastUri.exports;
|
|
528
|
+
hasRequiredFastUri = 1;
|
|
529
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = /* @__PURE__ */ requireUtils();
|
|
530
|
+
const { SCHEMES, getSchemeHandler } = /* @__PURE__ */ requireSchemes();
|
|
531
|
+
function normalize(uri, options) {
|
|
532
|
+
if (typeof uri === "string") {
|
|
533
|
+
uri = /** @type {T} */
|
|
534
|
+
normalizeString(uri, options);
|
|
535
|
+
} else if (typeof uri === "object") {
|
|
536
|
+
uri = /** @type {T} */
|
|
537
|
+
parse(serialize(uri, options), options);
|
|
538
|
+
}
|
|
539
|
+
return uri;
|
|
540
|
+
}
|
|
541
|
+
function resolve(baseURI, relativeURI, options) {
|
|
542
|
+
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
543
|
+
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
544
|
+
schemelessOptions.skipEscape = true;
|
|
545
|
+
return serialize(resolved, schemelessOptions);
|
|
546
|
+
}
|
|
547
|
+
function resolveComponent(base, relative, options, skipNormalization) {
|
|
548
|
+
const target = {};
|
|
549
|
+
if (!skipNormalization) {
|
|
550
|
+
base = parse(serialize(base, options), options);
|
|
551
|
+
relative = parse(serialize(relative, options), options);
|
|
552
|
+
}
|
|
553
|
+
options = options || {};
|
|
554
|
+
if (!options.tolerant && relative.scheme) {
|
|
555
|
+
target.scheme = relative.scheme;
|
|
556
|
+
target.userinfo = relative.userinfo;
|
|
557
|
+
target.host = relative.host;
|
|
558
|
+
target.port = relative.port;
|
|
559
|
+
target.path = removeDotSegments(relative.path || "");
|
|
560
|
+
target.query = relative.query;
|
|
561
|
+
} else {
|
|
562
|
+
if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
|
|
563
|
+
target.userinfo = relative.userinfo;
|
|
564
|
+
target.host = relative.host;
|
|
565
|
+
target.port = relative.port;
|
|
566
|
+
target.path = removeDotSegments(relative.path || "");
|
|
567
|
+
target.query = relative.query;
|
|
568
|
+
} else {
|
|
569
|
+
if (!relative.path) {
|
|
570
|
+
target.path = base.path;
|
|
571
|
+
if (relative.query !== void 0) {
|
|
572
|
+
target.query = relative.query;
|
|
573
|
+
} else {
|
|
574
|
+
target.query = base.query;
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
if (relative.path[0] === "/") {
|
|
578
|
+
target.path = removeDotSegments(relative.path);
|
|
579
|
+
} else {
|
|
580
|
+
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
581
|
+
target.path = "/" + relative.path;
|
|
582
|
+
} else if (!base.path) {
|
|
583
|
+
target.path = relative.path;
|
|
584
|
+
} else {
|
|
585
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
586
|
+
}
|
|
587
|
+
target.path = removeDotSegments(target.path);
|
|
588
|
+
}
|
|
589
|
+
target.query = relative.query;
|
|
590
|
+
}
|
|
591
|
+
target.userinfo = base.userinfo;
|
|
592
|
+
target.host = base.host;
|
|
593
|
+
target.port = base.port;
|
|
594
|
+
}
|
|
595
|
+
target.scheme = base.scheme;
|
|
596
|
+
}
|
|
597
|
+
target.fragment = relative.fragment;
|
|
598
|
+
return target;
|
|
599
|
+
}
|
|
600
|
+
function equal(uriA, uriB, options) {
|
|
601
|
+
const normalizedA = normalizeComparableURI(uriA, options);
|
|
602
|
+
const normalizedB = normalizeComparableURI(uriB, options);
|
|
603
|
+
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
|
|
604
|
+
}
|
|
605
|
+
function serialize(cmpts, opts) {
|
|
606
|
+
const component = {
|
|
607
|
+
host: cmpts.host,
|
|
608
|
+
scheme: cmpts.scheme,
|
|
609
|
+
userinfo: cmpts.userinfo,
|
|
610
|
+
port: cmpts.port,
|
|
611
|
+
path: cmpts.path,
|
|
612
|
+
query: cmpts.query,
|
|
613
|
+
nid: cmpts.nid,
|
|
614
|
+
nss: cmpts.nss,
|
|
615
|
+
uuid: cmpts.uuid,
|
|
616
|
+
fragment: cmpts.fragment,
|
|
617
|
+
reference: cmpts.reference,
|
|
618
|
+
resourceName: cmpts.resourceName,
|
|
619
|
+
secure: cmpts.secure,
|
|
620
|
+
error: ""
|
|
621
|
+
};
|
|
622
|
+
const options = Object.assign({}, opts);
|
|
623
|
+
const uriTokens = [];
|
|
624
|
+
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
625
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
626
|
+
if (component.path !== void 0) {
|
|
627
|
+
if (!options.skipEscape) {
|
|
628
|
+
component.path = escapePreservingEscapes(component.path);
|
|
629
|
+
if (component.scheme !== void 0) {
|
|
630
|
+
component.path = component.path.split("%3A").join(":");
|
|
631
|
+
}
|
|
632
|
+
} else {
|
|
633
|
+
component.path = normalizePercentEncoding(component.path);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (options.reference !== "suffix" && component.scheme) {
|
|
637
|
+
uriTokens.push(component.scheme, ":");
|
|
638
|
+
}
|
|
639
|
+
const authority = recomposeAuthority(component);
|
|
640
|
+
if (authority !== void 0) {
|
|
641
|
+
if (options.reference !== "suffix") {
|
|
642
|
+
uriTokens.push("//");
|
|
643
|
+
}
|
|
644
|
+
uriTokens.push(authority);
|
|
645
|
+
if (component.path && component.path[0] !== "/") {
|
|
646
|
+
uriTokens.push("/");
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
if (component.path !== void 0) {
|
|
650
|
+
let s = component.path;
|
|
651
|
+
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
652
|
+
s = removeDotSegments(s);
|
|
653
|
+
}
|
|
654
|
+
if (authority === void 0 && s[0] === "/" && s[1] === "/") {
|
|
655
|
+
s = "/%2F" + s.slice(2);
|
|
656
|
+
}
|
|
657
|
+
uriTokens.push(s);
|
|
658
|
+
}
|
|
659
|
+
if (component.query !== void 0) {
|
|
660
|
+
uriTokens.push("?", component.query);
|
|
661
|
+
}
|
|
662
|
+
if (component.fragment !== void 0) {
|
|
663
|
+
uriTokens.push("#", component.fragment);
|
|
664
|
+
}
|
|
665
|
+
return uriTokens.join("");
|
|
666
|
+
}
|
|
667
|
+
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
668
|
+
function getParseError(parsed, matches) {
|
|
669
|
+
if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
670
|
+
return 'URI path must start with "/" when authority is present.';
|
|
671
|
+
}
|
|
672
|
+
if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
|
|
673
|
+
return "URI port is malformed.";
|
|
674
|
+
}
|
|
675
|
+
return void 0;
|
|
676
|
+
}
|
|
677
|
+
function parseWithStatus(uri, opts) {
|
|
678
|
+
const options = Object.assign({}, opts);
|
|
679
|
+
const parsed = {
|
|
680
|
+
scheme: void 0,
|
|
681
|
+
userinfo: void 0,
|
|
682
|
+
host: "",
|
|
683
|
+
port: void 0,
|
|
684
|
+
path: "",
|
|
685
|
+
query: void 0,
|
|
686
|
+
fragment: void 0
|
|
687
|
+
};
|
|
688
|
+
let malformedAuthorityOrPort = false;
|
|
689
|
+
let isIP = false;
|
|
690
|
+
if (options.reference === "suffix") {
|
|
691
|
+
if (options.scheme) {
|
|
692
|
+
uri = options.scheme + ":" + uri;
|
|
693
|
+
} else {
|
|
694
|
+
uri = "//" + uri;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
const matches = uri.match(URI_PARSE);
|
|
698
|
+
if (matches) {
|
|
699
|
+
parsed.scheme = matches[1];
|
|
700
|
+
parsed.userinfo = matches[3];
|
|
701
|
+
parsed.host = matches[4];
|
|
702
|
+
parsed.port = parseInt(matches[5], 10);
|
|
703
|
+
parsed.path = matches[6] || "";
|
|
704
|
+
parsed.query = matches[7];
|
|
705
|
+
parsed.fragment = matches[8];
|
|
706
|
+
if (isNaN(parsed.port)) {
|
|
707
|
+
parsed.port = matches[5];
|
|
708
|
+
}
|
|
709
|
+
const parseError = getParseError(parsed, matches);
|
|
710
|
+
if (parseError !== void 0) {
|
|
711
|
+
parsed.error = parsed.error || parseError;
|
|
712
|
+
malformedAuthorityOrPort = true;
|
|
713
|
+
}
|
|
714
|
+
if (parsed.host) {
|
|
715
|
+
const ipv4result = isIPv4(parsed.host);
|
|
716
|
+
if (ipv4result === false) {
|
|
717
|
+
const ipv6result = normalizeIPv6(parsed.host);
|
|
718
|
+
parsed.host = ipv6result.host.toLowerCase();
|
|
719
|
+
isIP = ipv6result.isIPV6;
|
|
720
|
+
} else {
|
|
721
|
+
isIP = true;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) {
|
|
725
|
+
parsed.reference = "same-document";
|
|
726
|
+
} else if (parsed.scheme === void 0) {
|
|
727
|
+
parsed.reference = "relative";
|
|
728
|
+
} else if (parsed.fragment === void 0) {
|
|
729
|
+
parsed.reference = "absolute";
|
|
730
|
+
} else {
|
|
731
|
+
parsed.reference = "uri";
|
|
732
|
+
}
|
|
733
|
+
if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) {
|
|
734
|
+
parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
735
|
+
}
|
|
736
|
+
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
737
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
738
|
+
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
739
|
+
try {
|
|
740
|
+
parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
|
|
741
|
+
} catch (e) {
|
|
742
|
+
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
747
|
+
if (uri.indexOf("%") !== -1) {
|
|
748
|
+
if (parsed.scheme !== void 0) {
|
|
749
|
+
parsed.scheme = unescape(parsed.scheme);
|
|
750
|
+
}
|
|
751
|
+
if (parsed.host !== void 0) {
|
|
752
|
+
parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (parsed.path) {
|
|
756
|
+
parsed.path = normalizePathEncoding(parsed.path);
|
|
757
|
+
}
|
|
758
|
+
if (parsed.fragment) {
|
|
759
|
+
try {
|
|
760
|
+
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
|
|
761
|
+
} catch {
|
|
762
|
+
parsed.error = parsed.error || "URI malformed";
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (schemeHandler && schemeHandler.parse) {
|
|
767
|
+
schemeHandler.parse(parsed, options);
|
|
768
|
+
}
|
|
769
|
+
} else {
|
|
770
|
+
parsed.error = parsed.error || "URI can not be parsed.";
|
|
771
|
+
}
|
|
772
|
+
return { parsed, malformedAuthorityOrPort };
|
|
773
|
+
}
|
|
774
|
+
function parse(uri, opts) {
|
|
775
|
+
return parseWithStatus(uri, opts).parsed;
|
|
776
|
+
}
|
|
777
|
+
function normalizeString(uri, opts) {
|
|
778
|
+
return normalizeStringWithStatus(uri, opts).normalized;
|
|
779
|
+
}
|
|
780
|
+
function normalizeStringWithStatus(uri, opts) {
|
|
781
|
+
const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
|
|
782
|
+
return {
|
|
783
|
+
normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
|
|
784
|
+
malformedAuthorityOrPort
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
function normalizeComparableURI(uri, opts) {
|
|
788
|
+
if (typeof uri === "string") {
|
|
789
|
+
const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
|
|
790
|
+
return malformedAuthorityOrPort ? void 0 : normalized;
|
|
791
|
+
}
|
|
792
|
+
if (typeof uri === "object") {
|
|
793
|
+
return serialize(uri, opts);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
const fastUri$1 = {
|
|
797
|
+
SCHEMES,
|
|
798
|
+
normalize,
|
|
799
|
+
resolve,
|
|
800
|
+
resolveComponent,
|
|
801
|
+
equal,
|
|
802
|
+
serialize,
|
|
803
|
+
parse
|
|
804
|
+
};
|
|
805
|
+
fastUri.exports = fastUri$1;
|
|
806
|
+
fastUri.exports.default = fastUri$1;
|
|
807
|
+
fastUri.exports.fastUri = fastUri$1;
|
|
808
|
+
return fastUri.exports;
|
|
809
|
+
}
|
|
810
|
+
export {
|
|
811
|
+
requireFastUri as r
|
|
812
|
+
};
|