Skip to content

Commit 9953d5b

Browse files
authored
fix(sandbox): getInitialCode should not use URL hash without full prefix (#3523)
1 parent 57e19fd commit 9953d5b

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

.changeset/small-animals-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@typescript/sandbox": patch
3+
---
4+
5+
getInitialCode should not use URL hash without full prefix

packages/sandbox/src/getInitialCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import lzstring from "./vendor/lzstring.min"
77
*/
88
export const getInitialCode = (fallback: string, location: Location) => {
99
// Old school support
10-
if (location.hash.startsWith("#src")) {
10+
if (location.hash.startsWith("#src=")) {
1111
const code = location.hash.replace("#src=", "").trim()
1212
return decodeURIComponent(code)
1313
}
1414

1515
// New school support
16-
if (location.hash.startsWith("#code")) {
16+
if (location.hash.startsWith("#code/")) {
1717
const code = location.hash.replace("#code/", "").trim()
1818
let userCode = lzstring.decompressFromEncodedURIComponent(code)
1919
// Fallback incase there is an extra level of decoding:

0 commit comments

Comments
 (0)