Skip to content

Commit

Permalink
chore: remove unnecessary slice calls
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Oct 23, 2022
1 parent da78f8b commit 3a065e2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/asset.ts
Expand Up @@ -395,7 +395,7 @@ export function publicFileToBuiltUrl(
): string {
if (config.command !== 'build') {
// We don't need relative base or renderBuiltUrl support during dev
return joinUrlSegments(config.base, url.slice(1))
return joinUrlSegments(config.base, url)
}
const hash = getHash(url)
let cache = publicAssetUrlCache.get(config)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/css.ts
Expand Up @@ -213,7 +213,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
if (encodePublicUrlsInCSS(config)) {
return publicFileToBuiltUrl(url, config)
} else {
return joinUrlSegments(config.base, url.slice(1))
return joinUrlSegments(config.base, url)
}
}
const resolved = await resolveUrl(url, importer)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/middlewares/base.ts
Expand Up @@ -36,7 +36,7 @@ export function baseMiddleware({
return
} else if (req.headers.accept?.includes('text/html')) {
// non-based page visit
const redirectPath = joinUrlSegments(config.base, url.slice(1))
const redirectPath = joinUrlSegments(config.base, url)
res.writeHead(404, {
'Content-Type': 'text/html'
})
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/middlewares/indexHtml.ts
Expand Up @@ -94,7 +94,7 @@ const processNodeUrl = (
const devBase = config.base
if (startsWithSingleSlashRE.test(url)) {
// prefix with base (dev only, base is never relative)
const fullUrl = joinUrlSegments(devBase, url.slice(1))
const fullUrl = joinUrlSegments(devBase, url)
overwriteAttrValue(s, sourceCodeLocation, fullUrl)
} else if (
url.startsWith('.') &&
Expand Down Expand Up @@ -134,7 +134,7 @@ const devHtmlHook: IndexHtmlTransformHook = async (
const trailingSlash = htmlPath.endsWith('/')
if (!trailingSlash && fs.existsSync(filename)) {
proxyModulePath = htmlPath
proxyModuleUrl = joinUrlSegments(base, htmlPath.slice(1))
proxyModuleUrl = joinUrlSegments(base, htmlPath)
} else {
// There are users of vite.transformIndexHtml calling it with url '/'
// for SSR integrations #7993, filename is root for this case
Expand Down

0 comments on commit 3a065e2

Please sign in to comment.