diff --git a/packages/node_modules/pouchdb-adapter-http/src/index.js b/packages/node_modules/pouchdb-adapter-http/src/index.js index f967fb145e..4575180965 100644 --- a/packages/node_modules/pouchdb-adapter-http/src/index.js +++ b/packages/node_modules/pouchdb-adapter-http/src/index.js @@ -16,7 +16,6 @@ import { adapterFun as coreAdapterFun, explainError, clone, - parseUri, bulkGetShim, nextTick } from 'pouchdb-utils'; @@ -79,8 +78,8 @@ function hasUrlPrefix(opts) { if (!opts.prefix) { return false; } - const protocol = parseUri(opts.prefix).protocol; - return protocol === 'http' || protocol === 'https'; + const protocol = new URL(opts.prefix).protocol; + return protocol === 'http:' || protocol === 'https:'; } // Get all the information you possibly can about the URI given by name and @@ -94,24 +93,30 @@ function getHost(name, opts) { name = prefix + encodeURIComponent(dbName); } - const uri = parseUri(name); - if (uri.user || uri.password) { - uri.auth = {username: uri.user, password: uri.password}; + const url = new URL(name); + const uri = { + protocol: url.protocol.replace(/:$/, ''), + host: url.hostname, + port: url.port, + }; + + if (url.user || url.password) { + host.auth = {username: url.username, password: url.password}; } // Split the path part of the URI into parts using '/' as the delimiter // after removing any leading '/' and any trailing '/' - const parts = uri.path.replace(/(^\/|\/$)/g, '').split('/'); + const parts = url.pathname.replace(/(^\/|\/$)/g, '').split('/'); - uri.db = parts.pop(); + host.db = parts.pop(); // Prevent double encoding of URI component - if (uri.db.indexOf('%') === -1) { - uri.db = encodeURIComponent(uri.db); + if (host.db.indexOf('%') === -1) { + host.db = encodeURIComponent(uri.db); } - uri.path = parts.join('/'); + host.path = parts.join('/'); - return uri; + return host; } // Generate a URL with the host data given by opts and the given path diff --git a/packages/node_modules/pouchdb-for-coverage/src/utils.js b/packages/node_modules/pouchdb-for-coverage/src/utils.js index f86ebcde84..e6c1af189a 100644 --- a/packages/node_modules/pouchdb-for-coverage/src/utils.js +++ b/packages/node_modules/pouchdb-for-coverage/src/utils.js @@ -6,7 +6,6 @@ // import { - parseUri, uuid, rev, clone, @@ -49,7 +48,6 @@ import checkpointer from 'pouchdb-checkpointer'; export default { blob, - parseUri, uuid, rev, atob, diff --git a/packages/node_modules/pouchdb-utils/src/index.js b/packages/node_modules/pouchdb-utils/src/index.js index 19b4fe8a74..0731cdc75d 100644 --- a/packages/node_modules/pouchdb-utils/src/index.js +++ b/packages/node_modules/pouchdb-utils/src/index.js @@ -17,7 +17,6 @@ import nextTick from './nextTick'; import normalizeDdocFunctionName from './normalizeDdocFunctionName'; import once from './once'; import parseDdocFunctionName from './parseDdocFunctionName'; -import parseUri from './parseUri'; import pick from './pick'; import scopeEval from './scopeEval'; import toPromise from './toPromise'; @@ -44,7 +43,6 @@ export { normalizeDdocFunctionName, once, parseDdocFunctionName, - parseUri, pick, rev, scopeEval, diff --git a/packages/node_modules/pouchdb-utils/src/parseUri.js b/packages/node_modules/pouchdb-utils/src/parseUri.js deleted file mode 100644 index 6404ceb3b3..0000000000 --- a/packages/node_modules/pouchdb-utils/src/parseUri.js +++ /dev/null @@ -1,35 +0,0 @@ -// originally parseUri 1.2.2, now patched by us -// (c) Steven Levithan -// MIT License -var keys = ["source", "protocol", "authority", "userInfo", "user", "password", - "host", "port", "relative", "path", "directory", "file", "query", "anchor"]; -var qName ="queryKey"; -var qParser = /(?:^|&)([^&=]*)=?([^&]*)/g; - -// use the "loose" parser -/* eslint no-useless-escape: 0 */ -var parser = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; - -function parseUri(str) { - var m = parser.exec(str); - var uri = {}; - var i = 14; - - while (i--) { - var key = keys[i]; - var value = m[i] || ""; - var encoded = ['user', 'password'].indexOf(key) !== -1; - uri[key] = encoded ? decodeURIComponent(value) : value; - } - - uri[qName] = {}; - uri[keys[12]].replace(qParser, function ($0, $1, $2) { - if ($1) { - uri[qName][$1] = $2; - } - }); - - return uri; -} - -export default parseUri;