Skip to content

Commit

Permalink
Merge pull request #289 from Runrioter/master
Browse files Browse the repository at this point in the history
refactor: use native url lib
  • Loading branch information
glenjamin committed Mar 3, 2018
2 parents 6b756cc + 7837da1 commit c975a09
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions helpers.js
@@ -1,8 +1,9 @@
exports.pathMatch = pathMatch;
var parse = require('url').parse;

function pathMatch(url, path) {
if (url == path) return true;
var q = url.indexOf('?');
if (q == -1) return false;
return url.substring(0, q) == path;
exports.pathMatch = function(url, path) {
try {
return parse(url).pathname === path;
} catch (e) {
return false;
}
}

0 comments on commit c975a09

Please sign in to comment.