From 1d5f69704ae835edf1f5811594cc83583eab8409 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 25 Aug 2012 18:41:13 -0600 Subject: [PATCH] Clean paths so they start with one slash. --- .../public/gollum/livepreview/js/livepreview.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js index e2b1700b..e420b9e9 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js @@ -99,13 +99,21 @@ $.save = function( commitMessage ) { var msg = defaultCommitMessage(); var newLocation = baseUrl; + function clean( str ) { + return str.replace(/^\/+/g, '/'); + } + // 'a%2Fb' => a/b - if (pathName) { - newLocation += '/' + unescape(pathName); + if ( pathName ) { + pathName = unescape( pathName ); + newLocation += '/' + pathName; pathName = pathName + '/'; // pathName must end with / + + pathName = clean( pathName ); } newLocation += '/' + pageName; + newLocation = clean( newLocation ); // if &create=true then handle create instead of edit. if ( create ) {