Fix path
.key now returns undefined on failure so path can be 0. If path is undefined then use an empty string.
This commit is contained in:
@@ -62,9 +62,10 @@ initAce( commentEditor, commentEditorSession );
|
||||
var baseUrl = location.pathname.split('/').slice(0,-2).join('/');
|
||||
|
||||
// RegExp from http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
|
||||
// Returns value on success and undefined on failure.
|
||||
$.key = function( key ) {
|
||||
var value = new RegExp( '[\\?&]' + key + '=([^&#]*)' ).exec( location.href );
|
||||
return ( !value ) ? 0 : value[ 1 ] || 0;
|
||||
return ( !value ) ? undefined : value[ 1 ] || undefined;
|
||||
}
|
||||
|
||||
// True if &create=true
|
||||
@@ -341,9 +342,9 @@ var applyTimeout = function () {
|
||||
/* Load markdown from /data/page into the ace editor.
|
||||
~-1 == false; !~-1 == true;
|
||||
*/
|
||||
if ( !~location.host.indexOf('github.com') ) {
|
||||
if ( !~ location.host.indexOf( 'github.com' ) ) {
|
||||
// ensure leading / is removed from path and that it ends with /
|
||||
var path = unescape($.key( 'path' )).replace(/^\/+/, '');
|
||||
var path = unescape( $.key( 'path' ) || '' ).replace( /^\/+/, '' );
|
||||
if ( path.charAt( path.length - 1 ) !== '/' ) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user