From 5ae772cdc59f1279ff89ea007a16f55c9dc39ec4 Mon Sep 17 00:00:00 2001 From: Bart Flaherty Date: Sun, 26 Jul 2015 04:26:37 -0400 Subject: [PATCH] With no root specified, don't error --- aviator.js | 11 +++++++++-- src/navigator.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/aviator.js b/aviator.js index ff634d4..3c428ba 100644 --- a/aviator.js +++ b/aviator.js @@ -627,9 +627,16 @@ Navigator.prototype = { @return {String} uri '/s/foo-bar' **/ _removeURIRoot: function (uri) { - var rootRegex = new RegExp('^' + this.root); + var rootRegex; - return uri.replace(rootRegex, ''); + if (this.root) { + rootRegex = new RegExp('^' + this.root); + + return uri.replace(rootRegex, ''); + } + else { + return uri; + } }, /** diff --git a/src/navigator.js b/src/navigator.js index ccd6c95..a2bac93 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -376,9 +376,16 @@ Navigator.prototype = { @return {String} uri '/s/foo-bar' **/ _removeURIRoot: function (uri) { - var rootRegex = new RegExp('^' + this.root); + var rootRegex; - return uri.replace(rootRegex, ''); + if (this.root) { + rootRegex = new RegExp('^' + this.root); + + return uri.replace(rootRegex, ''); + } + else { + return uri; + } }, /**