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

Function configFromEmbedded

static/main.ts:263–297  ·  view source on GitHub ↗
(embeddedUrl: string, defaultLangId: string)

Source from the content-addressed store, hash-verified

261}
262
263function configFromEmbedded(embeddedUrl: string, defaultLangId: string) {
264 // Old-style link?
265 let params;
266 try {
267 params = unrisonify(embeddedUrl);
268 } catch {
269 document.write(
270 '<div style="padding: 10px; background: #fa564e; color: black;">' +
271 "An error was encountered while decoding the URL for this embed. Make sure the URL hasn't been " +
272 'truncated, otherwise if you believe your URL is valid please let us know on ' +
273 '<a href="https://github.com/compiler-explorer/compiler-explorer/issues" style="color: black;">' +
274 'our github' +
275 '</a>.' +
276 '</div>',
277 );
278 throw new Error('Embed url decode error');
279 }
280 if (params?.source && params.compiler) {
281 const filters: ParseFiltersAndOutputOptions = Object.fromEntries(
282 ((params.filters as string) || '').split(',').map(o => [o, true]),
283 );
284 return {
285 content: [
286 {
287 type: 'row',
288 content: [
289 Components.getEditorWith(1, params.source, filters, defaultLangId),
290 Components.getCompilerWith(1, filters, params.options, params.compiler),
291 ],
292 },
293 ],
294 };
295 }
296 return deserialiseState(embeddedUrl);
297}
298
299function fixBugsInConfig(config: Partial<GoldenLayout.Config & {activeItemIndex?: number}>): void {
300 if (config.activeItemIndex && config.activeItemIndex >= unwrap(config.content).length) {

Callers 1

findConfigFunction · 0.85

Calls 2

unrisonifyFunction · 0.85
deserialiseStateFunction · 0.70

Tested by

no test coverage detected