Skip to content

Commit

Permalink
fix: always normalize fs prefix slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 28, 2021
1 parent b2110af commit 99e4edd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function fileToDevUrl(id: string, { root, base }: ResolvedConfig) {
} else {
// outside of project root, use absolute fs path
// (this is special handled by the serve static middleware
rtn = FS_PREFIX + id
rtn = path.posix.join(FS_PREFIX + id)
}
return base + rtn.replace(/^\//, '')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
url = resolved.id.slice(config.root.length)
} else if (fs.existsSync(cleanUrl(resolved.id))) {
// exists but out of root: rewrite to absolute /@fs/ paths
url = FS_PREFIX + resolved.id
url = path.posix.join(FS_PREFIX + resolved.id)
} else {
url = resolved.id
}
Expand Down
5 changes: 0 additions & 5 deletions packages/vite/src/node/server/middlewares/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import chalk from 'chalk'
import {
DEP_CACHE_DIR,
DEP_VERSION_RE,
FS_PREFIX,
NULL_BYTE_PLACEHOLDER,
VALID_ID_PREFIX
} from '../../constants'
Expand Down Expand Up @@ -55,10 +54,6 @@ export function transformMiddleware(
const isSourceMap = withoutQuery.endsWith('.map')
// since we generate source map references, handle those requests here
if (isSourceMap) {
// #1323 - browser may remove // when fetching source maps
if (url.startsWith(FS_PREFIX)) {
url = FS_PREFIX + url.split(FS_PREFIX)[1].replace(/^\/?/, '/')
}
const originalUrl = url.replace(/\.map($|\?)/, '$1')
const map = (await moduleGraph.getModuleByUrl(originalUrl))
?.transformResult?.map
Expand Down

0 comments on commit 99e4edd

Please sign in to comment.