mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-09 11:34:24 +08:00
Fix multislashes
This commit is contained in:
@@ -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
|
||||
)
|
||||
]
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user