Are you an LLM? You can read better optimized documentation at /vite-press/frontend/code/normalize.md for this page in Markdown format
node 路径归一化
ts
import { posix } from 'path'
export const isPlatform = (platform: NodeJS.Platform) => {
return process && platform === process.platform
}
export const isWin = isPlatform('win32')
export const normalizePath = (id: string): string => {
const windowsSlashRE = /\\/g
const slash = (p: string): string => p.replace(windowsSlashRE, '/')
return posix.normalize(isWin ? slash(id) : id)
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17