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 ) {