MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / deserialiseState

Function deserialiseState

static/url.ts:78–106  ·  view source on GitHub ↗
(stateText: string)

Source from the content-addressed store, hash-verified

76}
77
78export function deserialiseState(stateText: string): any {
79 let state;
80 let exception;
81 try {
82 state = urlSerialization.unrisonify(stateText);
83 if (state?.z) {
84 const data = lzstring.decompressFromBase64(state.z);
85 // If lzstring fails to decompress this it'll return an empty string rather than throwing an error
86 if (data === '') {
87 throw new Error('lzstring decompress error, url is corrupted');
88 }
89 state = urlSerialization.unrisonify(data);
90 }
91 } catch (ex) {
92 exception = ex;
93 }
94
95 // This handles prehistoric urls, assumes rison fails with an error
96 if (!state) {
97 try {
98 state = JSON.parse(decodeURIComponent(stateText));
99 exception = null;
100 } catch (ex) {
101 if (!exception) exception = ex;
102 }
103 }
104 if (exception) throw exception;
105 return loadState(state);
106}

Callers 3

configFromEmbeddedFunction · 0.70
findConfigFunction · 0.70
url-tests.tsFile · 0.50

Calls 2

loadStateFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected