Skip to content

Commit

Permalink
(#150) Replace base URL regex with url-parse
Browse files Browse the repository at this point in the history
Reimplements #160.

Closes #150.
Closes #160.
  • Loading branch information
tlvince committed Nov 15, 2017
1 parent 3e6ce19 commit ef607b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict';

var urlJoin = require('url-join');
var urlParse = require('url-parse');

function getBaseUrl(db) {
if (typeof db.getUrl === 'function') { // pouchdb pre-6.0.0
return db.getUrl().replace(/\/[^\/]+\/?$/, '');
return urlParse(db.getUrl()).origin;
} else { // pouchdb post-6.0.0
return db.name.replace(/\/[^\/]+\/?$/, '');
return urlParse(db.name).origin;
}
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"pouchdb-extend": "0.1.2",
"pouchdb-promise": "6.3.4",
"pouchdb-utils": "6.3.4",
"url-join": "2.0.2"
"url-join": "2.0.2",
"url-parse": "1.2.0"
},
"devDependencies": {
"bluebird": "^3.5.1",
Expand Down

0 comments on commit ef607b5

Please sign in to comment.