Skip to content

Commit 7472135

Browse files
tlvinceptitjes
authored andcommitted
fix(urls): replace base URL regex with url-parse
Reimplements #160. Closes #150. Closes #160.
1 parent d600426 commit 7472135

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

package-lock.json

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"pouchdb-extend": "0.1.2",
4242
"pouchdb-promise": "6.3.4",
4343
"pouchdb-utils": "6.3.4",
44-
"url-join": "2.0.2"
44+
"url-join": "2.0.2",
45+
"url-parse": "1.2.0"
4546
},
4647
"devDependencies": {
4748
"babel-preset-env": "^1.6.1",

src/utils.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
'use strict';
22

33
import urlJoin from 'url-join';
4+
import urlParse from 'url-parse';
45

56
function getBaseUrl(db) {
67
if (typeof db.getUrl === 'function') { // pouchdb pre-6.0.0
7-
return db.getUrl().replace(/[^/]+\/?$/, '');
8+
return urlParse(db.getUrl()).origin;
89
} else if (db.__opts && db.__opts.prefix) { // PouchDB.defaults
910
return db.__opts.prefix;
1011
} else { // pouchdb post-6.0.0
11-
return db.name.replace(/[^/]+\/?$/, '');
12+
return urlParse(db.name).origin;
1213
}
1314
}
1415

0 commit comments

Comments
 (0)