mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
1 line
18 KiB
Plaintext
1 line
18 KiB
Plaintext
|
{"version":3,"file":"index.mjs","sources":["../src/format.js","../third_party/format.js","../src/constants.js","../src/parse.js","../src/resolve.js"],"sourcesContent":["/*\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the 'License');\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an 'AS IS' BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport qs from 'querystring';\nimport parse from './parse';\nimport format from '../third_party/format';\n\nconst slashedProtocols = /https?|ftp|gopher|file/;\n\nexport default function(urlObj) {\n if (typeof urlObj === 'string') {\n urlObj = parse(urlObj);\n }\n\n const { protocol, host, pathname, search, hash } = format(\n urlObj,\n qs,\n slashedProtocols\n );\n\n return `${protocol}${host}${pathname}${search}${hash}`;\n}\n","// Format function modified from nodejs\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nexport default function(urlObj, qs, slashedProtocols) {\n let { auth, hostname } = urlObj;\n let protocol = urlObj.protocol || '';\n let pathname = urlObj.pathname || '';\n let hash = urlObj.hash || '';\n let query = urlObj.query || '';\n let host = false;\n\n auth = auth ? encodeURIComponent(auth).replace(/%3A/i, ':') + '@' : '';\n\n if (urlObj.host) {\n host = auth + urlObj.host;\n } else if (hostname) {\n host = auth + (~hostname.indexOf(':') ? `[${hostname}]` : hostname);\n if (urlObj.port) {\n host += ':' + urlObj.port;\n }\n }\n\n if (query && typeof query === 'object') {\n // query = '' + new URLSearchParams(query);\n query = qs.encode(query);\n }\n\n let search = urlObj.search || (query && `?${query}`) || '';\n\n if (protocol && protocol.substr(-1) !== ':') protocol += ':';\n\n if (\n urlObj.slashes ||\n ((!protocol || slashedProtocols.test(protocol)) && host !== false)\n ) {\n host = '//' + (host || '');\n if (pathname && pathname[0] !== '/') pathname = '/' + pathname;\n } else if (!host) {\n host = '';\n }\n\n if (hash && hash[0] !== '#') hash = '#' + hash;\n if (search && search[0] !== '?') search = '?' + search;\n\n pathname = pathname.replace(/[?#]/g, encodeURIComponent);\n search = search.replace('#', '%23');\n\n return {\n protocol,\n host,\n pathname,\n search,\n hash\n };\n}\n","/*\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the 'License');\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2
|