diff --git a/index.coffee b/index.coffee index af67590..66eb1ba 100644 --- a/index.coffee +++ b/index.coffee @@ -100,7 +100,7 @@ export shouldOpenInNewWindow = (url) -> # add trailing slash export addTrailingSlash = (to) -> url = new URL to - url.pathname += if url.pathname.endsWith "/" then "" else "/" + url.pathname += if url.pathname.match(/\/$/) then "" else "/" url.toString() # Directive definition with settings method for overriding the default settings. diff --git a/index.js b/index.js index 6ce14f9..00de52e 100644 --- a/index.js +++ b/index.js @@ -179,13 +179,11 @@ var shouldOpenInNewWindow = exports.shouldOpenInNewWindow = function shouldOpenI var addTrailingSlash = exports.addTrailingSlash = function addTrailingSlash(to) { var url; url = new _urlParse2.default(to); - url.pathname += url.pathname.endsWith("/") ? "" : "/"; + url.pathname += url.pathname.match(/\/$/) ? "" : "/"; return url.toString(); }; exports.default = { - // if to.match /\/$/ then to else to + '/' - // Directive definition with settings method for overriding the default settings. // I'm relying on Browser garbage collection to cleanup listeners. bind: bind,