diff --git a/.changeset/small-animals-switch.md b/.changeset/small-animals-switch.md new file mode 100644 index 000000000000..9e3c8420a2ad --- /dev/null +++ b/.changeset/small-animals-switch.md @@ -0,0 +1,5 @@ +--- +"@typescript/sandbox": patch +--- + +getInitialCode should not use URL hash without full prefix diff --git a/packages/sandbox/src/getInitialCode.ts b/packages/sandbox/src/getInitialCode.ts index 3e712c091c4e..9190fdea2a61 100644 --- a/packages/sandbox/src/getInitialCode.ts +++ b/packages/sandbox/src/getInitialCode.ts @@ -7,13 +7,13 @@ import lzstring from "./vendor/lzstring.min" */ export const getInitialCode = (fallback: string, location: Location) => { // Old school support - if (location.hash.startsWith("#src")) { + if (location.hash.startsWith("#src=")) { const code = location.hash.replace("#src=", "").trim() return decodeURIComponent(code) } // New school support - if (location.hash.startsWith("#code")) { + if (location.hash.startsWith("#code/")) { const code = location.hash.replace("#code/", "").trim() let userCode = lzstring.decompressFromEncodedURIComponent(code) // Fallback incase there is an extra level of decoding: