(
specifier: string,
importMap: {[specifier: string]: string},
baseUrl: string,
)
| 52 | /^https?:\/\//.test(url) ? url : new URL(url, baseUrl).href; |
| 53 | |
| 54 | const getMappedImportUrl = ( |
| 55 | specifier: string, |
| 56 | importMap: {[specifier: string]: string}, |
| 57 | baseUrl: string, |
| 58 | ): string | undefined => { |
| 59 | const exact = importMap[specifier]; |
| 60 | if (exact != null) { |
| 61 | return absolutizeImportUrl(exact, baseUrl); |
| 62 | } |
| 63 | const prefix = Object.keys(importMap) |
| 64 | .filter((key) => specifier.startsWith(key + '/')) |
| 65 | .sort((a, b) => b.length - a.length)[0]; |
| 66 | return prefix == null |
| 67 | ? undefined |
| 68 | : absolutizeImportUrl( |
| 69 | importMap[prefix]! + specifier.slice(prefix.length), |
| 70 | baseUrl, |
| 71 | ); |
| 72 | }; |
| 73 | |
| 74 | export const getPublishedImportUrl = ( |
| 75 | specifier: string, |
no test coverage detected
searching dependent graphs…