Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
fix: ignore import transform for absolute urls (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Sep 7, 2021
1 parent 1ba366f commit 0311694
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/template/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export function urlToRequire(
transformAssetUrlsOption: TransformAssetUrlsOptions = {}
): string {
const returnValue = `"${url}"`
if (isExternalUrl(url) || isDataUrl(url) || isHashUrl(url)) {
if (
isExternalUrl(url) ||
isDataUrl(url) ||
isHashUrl(url) ||
isAbsolute(url)
) {
return returnValue
}
// same logic as in transform-require.js
Expand Down Expand Up @@ -61,6 +66,10 @@ export function isDataUrl(url: string): boolean {
return dataUrlRE.test(url)
}

export function isAbsolute(url: string): boolean {
return url.startsWith('/')
}

/**
* vuejs/component-compiler-utils#22 Support uri fragment in transformed require
* @param urlString an url as a string
Expand Down

0 comments on commit 0311694

Please sign in to comment.