1 line
15 KiB
JSON
1 line
15 KiB
JSON
{"ast":null,"code":"\"use strict\";\n\n// URI parser based on RFC 3986\n// We can't use the standard `URL` object, because we want to support relative `file:` URLs like\n// `file:relative/path/database.db`, which are not correct according to RFC 8089, which standardizes the\n// `file` scheme.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.encodeBaseUrl = exports.parseUri = void 0;\nconst api_js_1 = require(\"./api.js\");\nfunction parseUri(text) {\n const match = URI_RE.exec(text);\n if (match === null) {\n throw new api_js_1.LibsqlError(`The URL '${text}' is not in a valid format`, \"URL_INVALID\");\n }\n const groups = match.groups;\n const scheme = groups[\"scheme\"];\n const authority = groups[\"authority\"] !== undefined ? parseAuthority(groups[\"authority\"]) : undefined;\n const path = percentDecode(groups[\"path\"]);\n const query = groups[\"query\"] !== undefined ? parseQuery(groups[\"query\"]) : undefined;\n const fragment = groups[\"fragment\"] !== undefined ? percentDecode(groups[\"fragment\"]) : undefined;\n return {\n scheme,\n authority,\n path,\n query,\n fragment\n };\n}\nexports.parseUri = parseUri;\nconst URI_RE = (() => {\n const SCHEME = \"(?<scheme>[A-Za-z][A-Za-z.+-]*)\";\n const AUTHORITY = \"(?<authority>[^/?#]*)\";\n const PATH = \"(?<path>[^?#]*)\";\n const QUERY = \"(?<query>[^#]*)\";\n const FRAGMENT = \"(?<fragment>.*)\";\n return new RegExp(`^${SCHEME}:(//${AUTHORITY})?${PATH}(\\\\?${QUERY})?(#${FRAGMENT})?$`, \"su\");\n})();\nfunction parseAuthority(text) {\n const match = AUTHORITY_RE.exec(text);\n if (match === null) {\n throw new api_js_1.LibsqlError(\"The authority part of the URL is not in a valid format\", \"URL_INVALID\");\n }\n const groups = match.groups;\n const host = percentDecode(groups[\"host_br\"] ?? groups[\"host\"]);\n const port = groups[\"port\"] ? parseInt(groups[\"port\"], 10) : undefined;\n const userinfo = groups[\"username\"] !== undefined ? {\n username: percentDecode(groups[\"username\"]),\n password: groups[\"password\"] !== undefined ? percentDecode(groups[\"password\"]) : undefined\n } : undefined;\n return {\n host,\n port,\n userinfo\n };\n}\nconst AUTHORITY_RE = (() => {\n return new RegExp(`^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\\\[\\\\]]*)|(\\\\[(?<host_br>[^\\\\[\\\\]]*)\\\\]))(:(?<port>[0-9]*))?$`, \"su\");\n})();\n// Query string is parsed as application/x-www-form-urlencoded according to the Web URL standard:\n// https://url.spec.whatwg.org/#urlencoded-parsing\nfunction parseQuery(text) {\n const sequences = text.split(\"&\");\n const pairs = [];\n for (const sequence of sequences) {\n if (sequence === \"\") {\n continue;\n }\n let key;\n let value;\n const splitIdx = sequence.indexOf(\"=\");\n if (splitIdx < 0) {\n key = sequence;\n value = \"\";\n } else {\n key = sequence.substring(0, splitIdx);\n value = sequence.substring(splitIdx + 1);\n }\n pairs.push({\n key: percentDecode(key.replaceAll(\"+\", \" \")),\n value: percentDecode(value.replaceAll(\"+\", \" \"))\n });\n }\n return {\n pairs\n };\n}\nfunction percentDecode(text) {\n try {\n return decodeURIComponent(text);\n } catch (e) {\n if (e instanceof URIError) {\n throw new api_js_1.LibsqlError(`URL component has invalid percent encoding: ${e}`, \"URL_INVALID\", undefined, e);\n }\n throw e;\n }\n}\nfunction encodeBaseUrl(scheme, authority, path) {\n if (authority === undefined) {\n throw new api_js_1.LibsqlError(`URL with scheme ${JSON.stringify(scheme + \":\")} requires authority (the \"//\" part)`, \"URL_INVALID\");\n }\n const schemeText = `${scheme}:`;\n const hostText = encodeHost(authority.host);\n const portText = encodePort(authority.port);\n const userinfoText = encodeUserinfo(authority.userinfo);\n const authorityText = `//${userinfoText}${hostText}${portText}`;\n let pathText = path.split(\"/\").map(encodeURIComponent).join(\"/\");\n if (pathText !== \"\" && !pathText.startsWith(\"/\")) {\n pathText = \"/\" + pathText;\n }\n return new URL(`${schemeText}${authorityText}${pathText}`);\n}\nexports.encodeBaseUrl = encodeBaseUrl;\nfunction encodeHost(host) {\n return host.includes(\":\") ? `[${encodeURI(host)}]` : encodeURI(host);\n}\nfunction encodePort(port) {\n return port !== undefined ? `:${port}` : \"\";\n}\nfunction encodeUserinfo(userinfo) {\n if (userinfo === undefined) {\n return \"\";\n }\n const usernameText = encodeURIComponent(userinfo.username);\n const passwordText = userinfo.password !== undefined ? `:${encodeURIComponent(userinfo.password)}` : \"\";\n return `${usernameText}${passwordText}@`;\n}","map":{"version":3,"names":["Object","defineProperty","exports","value","encodeBaseUrl","parseUri","api_js_1","require","text","match","URI_RE","exec","LibsqlError","groups","scheme","authority","undefined","parseAuthority","path","percentDecode","query","parseQuery","fragment","SCHEME","AUTHORITY","PATH","QUERY","FRAGMENT","RegExp","AUTHORITY_RE","host","port","parseInt","userinfo","username","password","sequences","split","pairs","sequence","key","splitIdx","indexOf","substring","push","replaceAll","decodeURIComponent","e","URIError","JSON","stringify","schemeText","hostText","encodeHost","portText","encodePort","userinfoText","encodeUserinfo","authorityText","pathText","map","encodeURIComponent","join","startsWith","URL","includes","encodeURI","usernameText","passwordText"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/core/lib-cjs/uri.js"],"sourcesContent":["\"use strict\";\n// URI parser based on RFC 3986\n// We can't use the standard `URL` object, because we want to support relative `file:` URLs like\n// `file:relative/path/database.db`, which are not correct according to RFC 8089, which standardizes the\n// `file` scheme.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.encodeBaseUrl = exports.parseUri = void 0;\nconst api_js_1 = require(\"./api.js\");\nfunction parseUri(text) {\n const match = URI_RE.exec(text);\n if (match === null) {\n throw new api_js_1.LibsqlError(`The URL '${text}' is not in a valid format`, \"URL_INVALID\");\n }\n const groups = match.groups;\n const scheme = groups[\"scheme\"];\n const authority = groups[\"authority\"] !== undefined\n ? parseAuthority(groups[\"authority\"])\n : undefined;\n const path = percentDecode(groups[\"path\"]);\n const query = groups[\"query\"] !== undefined ? parseQuery(groups[\"query\"]) : undefined;\n const fragment = groups[\"fragment\"] !== undefined\n ? percentDecode(groups[\"fragment\"])\n : undefined;\n return { scheme, authority, path, query, fragment };\n}\nexports.parseUri = parseUri;\nconst URI_RE = (() => {\n const SCHEME = \"(?<scheme>[A-Za-z][A-Za-z.+-]*)\";\n const AUTHORITY = \"(?<authority>[^/?#]*)\";\n const PATH = \"(?<path>[^?#]*)\";\n const QUERY = \"(?<query>[^#]*)\";\n const FRAGMENT = \"(?<fragment>.*)\";\n return new RegExp(`^${SCHEME}:(//${AUTHORITY})?${PATH}(\\\\?${QUERY})?(#${FRAGMENT})?$`, \"su\");\n})();\nfunction parseAuthority(text) {\n const match = AUTHORITY_RE.exec(text);\n if (match === null) {\n throw new api_js_1.LibsqlError(\"The authority part of the URL is not in a valid format\", \"URL_INVALID\");\n }\n const groups = match.groups;\n const host = percentDecode(groups[\"host_br\"] ?? groups[\"host\"]);\n const port = groups[\"port\"] ? parseInt(groups[\"port\"], 10) : undefined;\n const userinfo = groups[\"username\"] !== undefined\n ? {\n username: percentDecode(groups[\"username\"]),\n password: groups[\"password\"] !== undefined\n ? percentDecode(groups[\"password\"])\n : undefined,\n }\n : undefined;\n return { host, port, userinfo };\n}\nconst AUTHORITY_RE = (() => {\n return new RegExp(`^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\\\[\\\\]]*)|(\\\\[(?<host_br>[^\\\\[\\\\]]*)\\\\]))(:(?<port>[0-9]*))?$`, \"su\");\n})();\n// Query string is parsed as application/x-www-form-urlencoded according to the Web URL standard:\n// https://url.spec.whatwg.org/#urlencoded-parsing\nfunction parseQuery(text) {\n const sequences = text.split(\"&\");\n const pairs = [];\n for (const sequence of sequences) {\n if (sequence === \"\") {\n continue;\n }\n let key;\n let value;\n const splitIdx = sequence.indexOf(\"=\");\n if (splitIdx < 0) {\n key = sequence;\n value = \"\";\n }\n else {\n key = sequence.substring(0, splitIdx);\n value = sequence.substring(splitIdx + 1);\n }\n pairs.push({\n key: percentDecode(key.replaceAll(\"+\", \" \")),\n value: percentDecode(value.replaceAll(\"+\", \" \")),\n });\n }\n return { pairs };\n}\nfunction percentDecode(text) {\n try {\n return decodeURIComponent(text);\n }\n catch (e) {\n if (e instanceof URIError) {\n throw new api_js_1.LibsqlError(`URL component has invalid percent encoding: ${e}`, \"URL_INVALID\", undefined, e);\n }\n throw e;\n }\n}\nfunction encodeBaseUrl(scheme, authority, path) {\n if (authority === undefined) {\n throw new api_js_1.LibsqlError(`URL with scheme ${JSON.stringify(scheme + \":\")} requires authority (the \"//\" part)`, \"URL_INVALID\");\n }\n const schemeText = `${scheme}:`;\n const hostText = encodeHost(authority.host);\n const portText = encodePort(authority.port);\n const userinfoText = encodeUserinfo(authority.userinfo);\n const authorityText = `//${userinfoText}${hostText}${portText}`;\n let pathText = path.split(\"/\").map(encodeURIComponent).join(\"/\");\n if (pathText !== \"\" && !pathText.startsWith(\"/\")) {\n pathText = \"/\" + pathText;\n }\n return new URL(`${schemeText}${authorityText}${pathText}`);\n}\nexports.encodeBaseUrl = encodeBaseUrl;\nfunction encodeHost(host) {\n return host.includes(\":\") ? `[${encodeURI(host)}]` : encodeURI(host);\n}\nfunction encodePort(port) {\n return port !== undefined ? `:${port}` : \"\";\n}\nfunction encodeUserinfo(userinfo) {\n if (userinfo === undefined) {\n return \"\";\n }\n const usernameText = encodeURIComponent(userinfo.username);\n const passwordText = userinfo.password !== undefined\n ? `:${encodeURIComponent(userinfo.password)}`\n : \"\";\n return `${usernameText}${passwordText}@`;\n}\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACA;AACA;AACAA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,aAAa,GAAGF,OAAO,CAACG,QAAQ,GAAG,KAAK,CAAC;AACjD,MAAMC,QAAQ,GAAGC,OAAO,CAAC,UAAU,CAAC;AACpC,SAASF,QAAQA,CAACG,IAAI,EAAE;EACpB,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC;EA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