Fix multislashes

This commit is contained in:
Vit Brunner
2015-03-13 20:06:51 +01:00
parent c1dc77eb5b
commit add3e18d15
4 changed files with 20 additions and 5 deletions
@@ -45,7 +45,7 @@ angular.module("sideBySide").controller "ComparisonController",
# TODO else notification
load(
route.appUrl + '/' + route.params.base.replace /\./g, '/'
route.getBaseDir()
route.params.display
)
]
+1 -1
View File
@@ -6,7 +6,7 @@ angular.module("sideBySide").factory "fetch",
# @param base [String] Path to config file directory
# @return [Object] Promises and config data
(base) ->
file = base + '/config.json'
file = base + 'config.json'
$http.get(file).then (config) ->
if typeof config.data != "object"
throw "Config file " + file + " doesn't contain data."
+10 -3
View File
@@ -20,9 +20,9 @@ angular.module("sideBySide").service "route",
@params.base = '' if 'base' not of @params
absUrl = $location.absUrl()
@appUrl = absUrl.substring(0, absUrl.length - $location.url().length)
if @appUrl.substring(@appUrl.length - 2) == '/#'
@appUrl = @appUrl.substring(0, @appUrl.length - 2)
@appUrl = absUrl
.substring(0, absUrl.length - $location.url().length)
.replace /\/?#?$/, '' # remove / and # at string end
getValue = (value) ->
if typeof value == 'object'
@@ -38,6 +38,13 @@ angular.module("sideBySide").service "route",
key + ':' + getValue @params[key]
.join '/'
@getBaseDir = ->
base = '/'
if @params.base
base += @params.base.replace(/\./g, '/') + '/'
@appUrl + base
@update = (key, value) ->
@params[key] = value
$location.path @get()
+8
View File
@@ -23,6 +23,14 @@ test "gets parameters", ->
setup()
equal route.get(), 'base:asdf/section:7'
test "gets base dir", ->
setup()
equal route.getBaseDir(), 'http://example.com/asdf/'
test "gets more complicated base dir", ->
setup('http://example.com/path/#', '/base:test.this', '')
equal route.getBaseDir(), 'http://example.com/path/test/this/'
test "updates parameters", ->
setup()
route.update('base', 'zxcv')