(url: string)
| 583 | } |
| 584 | |
| 585 | async function loadText(url: string) { |
| 586 | if (url.startsWith('data:')) { |
| 587 | return await (await fetch(url)).text(); |
| 588 | } |
| 589 | |
| 590 | const cache = readCSSFetchCache(url); |
| 591 | if (cache) { |
| 592 | return cache; |
| 593 | } |
| 594 | |
| 595 | const parsedURL = new URL(url); |
| 596 | let text: string; |
| 597 | if (parsedURL.origin === location.origin) { |
| 598 | text = await loadAsText(url, 'text/css', location.origin); |
| 599 | } else { |
| 600 | text = await bgFetch({url, responseType: 'text', mimeType: 'text/css', origin: location.origin}); |
| 601 | } |
| 602 | if (parsedURL.origin === location.origin) { |
| 603 | writeCSSFetchCache(url, text); |
| 604 | } |
| 605 | return text; |
| 606 | } |
| 607 | |
| 608 | async function replaceCSSImports(cssText: string, basePath: string, cache = new Map<string, string>()) { |
| 609 | cssText = removeCSSComments(cssText); |
no test coverage detected