Skip to content

Commit

Permalink
perf: replace startsWith with === (#13989)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Jul 31, 2023
1 parent 1ab06a8 commit 3aab14e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/vite/src/node/plugins/assetImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
preferRelative: true,
})
file = await assetResolver(url, id)
file ??= url.startsWith('/')
? slash(path.join(config.publicDir, url))
: slash(path.resolve(path.dirname(id), url))
file ??=
url[0] === '/'
? slash(path.join(config.publicDir, url))
: slash(path.resolve(path.dirname(id), url))
}

// Get final asset URL. If the file does not exist,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/importMetaGlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ export async function toAbsoluteGlob(
if (glob.startsWith('../')) return pre + posix.join(dir, glob)
if (glob.startsWith('**')) return pre + glob

const isSubImportsPattern = glob.startsWith('#') && glob.includes('*')
const isSubImportsPattern = glob[0] === '#' && glob.includes('*')

const resolved = normalizePath(
(await resolveId(glob, importer, {
Expand Down

0 comments on commit 3aab14e

Please sign in to comment.