Skip to content

Commit

Permalink
fix: fix importing data url stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny committed Feb 2, 2024
1 parent 5db587c commit d57a06c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/livecodes/result/result-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const createResultPage = async ({

// stylesheets imported in script editor
const stylesheetImports = getImports(code.script.compiled).filter(
(mod) => mod.endsWith('.css') && !mod.startsWith('.'),
(mod) => (mod.endsWith('.css') && !mod.startsWith('.')) || mod.startsWith('data:text/css'),
);
stylesheetImports.forEach((mod) => {
const url = modulesService.getUrl(mod);
Expand Down
4 changes: 3 additions & 1 deletion src/livecodes/services/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export const modulesService = {
},

getUrl: (path: string, cdn?: CDN) =>
path.startsWith('http') ? path : getCdnUrl(path, false, cdn || getAppCDN()) || path,
path.startsWith('http') || path.startsWith('data:')
? path
: getCdnUrl(path, false, cdn || getAppCDN()) || path,

cdnLists: { npm: npmCDNs, module: moduleCDNs, gh: ghCDNs },

Expand Down
5 changes: 4 additions & 1 deletion src/livecodes/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ const removeCDNPrefix = (url: string) => {
return url;
};

const removeSpecifier = (type: string) => (type.includes(':') ? type.split(':')[1] : type);
const removeSpecifier = (type: string) =>
type.includes(':') && !type.startsWith('data:') && !type.startsWith('http')
? type.split(':')[1]
: type;

0 comments on commit d57a06c

Please sign in to comment.