(compSrcPath: string, relativePath: string)
| 42 | * the original path if no rewriting is needed. |
| 43 | */ |
| 44 | export function rewriteAssetPath(compSrcPath: string, relativePath: string): string { |
| 45 | if (isAbsoluteOrSpecial(relativePath)) return relativePath; |
| 46 | if (!needsRewrite(relativePath)) return relativePath; |
| 47 | const compDir = dirname(compSrcPath); |
| 48 | if (!compDir || compDir === ".") return relativePath; |
| 49 | const resolved = join(compDir, relativePath); |
| 50 | const normalized = resolve("/", resolved).slice(1); |
| 51 | return normalized; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Rewrite all relative `src` and `href` attributes on elements within a |
no test coverage detected