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('/');
|
var baseUrl = location.pathname.split('/').slice(0,-2).join('/');
|
||||||
|
|
||||||
// RegExp from http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
|
// RegExp from http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
|
||||||
|
// Returns value on success and undefined on failure.
|
||||||
$.key = function( key ) {
|
$.key = function( key ) {
|
||||||
var value = new RegExp( '[\\?&]' + key + '=([^&#]*)' ).exec( location.href );
|
var value = new RegExp( '[\\?&]' + key + '=([^&#]*)' ).exec( location.href );
|
||||||
return ( !value ) ? 0 : value[ 1 ] || 0;
|
return ( !value ) ? undefined : value[ 1 ] || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if &create=true
|
// True if &create=true
|
||||||
@@ -343,7 +344,7 @@ var applyTimeout = function () {
|
|||||||
*/
|
*/
|
||||||
if ( !~ location.host.indexOf( 'github.com' ) ) {
|
if ( !~ location.host.indexOf( 'github.com' ) ) {
|
||||||
// ensure leading / is removed from path and that it ends with /
|
// 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 ) !== '/' ) {
|
if ( path.charAt( path.length - 1 ) !== '/' ) {
|
||||||
path += '/';
|
path += '/';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user