Update get /data
Remove leading slash from page Fix edge case with path set to '/'
This commit is contained in:
@@ -339,15 +339,22 @@ var applyTimeout = function () {
|
||||
~-1 == false; !~-1 == true;
|
||||
*/
|
||||
if ( !~ location.host.indexOf( 'github.com' ) ) {
|
||||
|
||||
// returns unescaped key with leading slashes removed
|
||||
function key_no_leading_slash( key ) {
|
||||
return unescape( $.key( key ) || '' ).replace( /^\/+/, '' );
|
||||
}
|
||||
|
||||
// ensure leading / is removed from path and that it ends with /
|
||||
var path = unescape( $.key( 'path' ) || '' ).replace( /^\/+/, '' );
|
||||
if ( path.charAt( path.length - 1 ) !== '/' ) {
|
||||
var path = key_no_leading_slash( 'path' );
|
||||
// don't append '/' if path is empty from removing leading slash
|
||||
if ( path !== '' && path.charAt( path.length - 1 ) !== '/' ) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
jQuery.ajax( {
|
||||
type: 'GET',
|
||||
url: baseUrl + '/data/' + path + $.key( 'page' ),
|
||||
url: baseUrl + '/data/' + path + key_no_leading_slash( 'page' ),
|
||||
success: function( data ) {
|
||||
editorSession.setValue( data );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user