Fix bug with trailing `/`.

This commit is contained in:
Braydon Fuller 2015-10-13 11:16:12 -04:00
parent c45a0edd60
commit 7ec3124d82
1 changed files with 11 additions and 7 deletions

View File

@ -12,7 +12,11 @@ var InsightUI = function(options) {
} else { } else {
this.apiPrefix = 'insight-api'; this.apiPrefix = 'insight-api';
} }
if (typeof options.routePrefix !== 'undefined') {
this.routePrefix = options.routePrefix;
} else {
this.routePrefix = 'insight';
}
}; };
InsightUI.dependencies = ['insight-api']; InsightUI.dependencies = ['insight-api'];
@ -25,11 +29,7 @@ InsightUI.prototype.start = function(callback) {
}; };
InsightUI.prototype.getRoutePrefix = function() { InsightUI.prototype.getRoutePrefix = function() {
if (typeof this.routePrefix !== 'undefined') { return this.routePrefix;
return this.routePrefix;
} else {
return 'insight';
}
}; };
InsightUI.prototype.setupRoutes = function(app, express) { InsightUI.prototype.setupRoutes = function(app, express) {
@ -49,8 +49,12 @@ InsightUI.prototype.setupRoutes = function(app, express) {
InsightUI.prototype.filterIndexHTML = function(data) { InsightUI.prototype.filterIndexHTML = function(data) {
var transformed = data var transformed = data
.replace(/<base href=\"\/\"/, '<base href="/"')
.replace(/apiPrefix = '\/api'/, "apiPrefix = '/" + this.apiPrefix + "'"); .replace(/apiPrefix = '\/api'/, "apiPrefix = '/" + this.apiPrefix + "'");
if (this.routePrefix) {
transformed = transformed.replace(/<base href=\"\/\"/, '<base href="/' + this.routePrefix + '/"');
}
return transformed; return transformed;
}; };