File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ <h2 id="sprite-name"></h2>
77
77
}
78
78
79
79
function id_from_url ( url ) {
80
- if ( url . indexOf ( "#" ) !== - 1 ) url = url . slice ( 0 , url . indexOf ( "#" ) ) ;
81
- var id = ( url + " " ) . split ( / [ ^ 0 - 9 ] + / ) [ 1 ] ;
80
+ url = url . replace ( / - [ 0 - 9 ] + / g , '' ) ; // Remove numbers in comment anchors
81
+ var id = url . match ( / [ 0 - 9 ] + (? ! [ \s \S ] * [ 0 - 9 ] + ) / ) ; // Find the last number in the url
82
82
return id ;
83
83
}
84
84
@@ -343,7 +343,7 @@ <h2 id="sprite-name"></h2>
343
343
input . addEventListener ( 'input' , function ( e ) {
344
344
console . log ( input . value ) ;
345
345
var id = id_from_url ( input . value ) ;
346
- input . value = "http://scratch.mit.edu/projects/" + id ;
346
+ input . value = "http://scratch.mit.edu/projects/" + ( id || '' ) ;
347
347
console . log ( id ) ;
348
348
} ) ;
349
349
You can’t perform that action at this time.
0 commit comments