Skip to content

Commit 403e8ec

Browse files
committed
Merge pull request #3 from PullJosh/patch-1
Allow phosphorus links in generator
2 parents da315ee + 2d96ade commit 403e8ec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

generator/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ <h2 id="sprite-name"></h2>
7777
}
7878

7979
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
8282
return id;
8383
}
8484

@@ -343,7 +343,7 @@ <h2 id="sprite-name"></h2>
343343
input.addEventListener('input', function(e) {
344344
console.log(input.value);
345345
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 || '');
347347
console.log(id);
348348
});
349349

0 commit comments

Comments
 (0)