File tree Expand file tree Collapse file tree 4 files changed +5
-30
lines changed Expand file tree Collapse file tree 4 files changed +5
-30
lines changed Original file line number Diff line number Diff line change 1
1
import { siteDataRef } from './data.js'
2
- import { inBrowser , EXTERNAL_URL_RE , sanitizeFileName } from '../shared.js'
2
+ import { inBrowser , EXTERNAL_URL_RE } from '../shared.js'
3
3
4
4
export { inBrowser }
5
5
@@ -36,18 +36,14 @@ export function pathToFile(path: string): string {
36
36
if ( inBrowser ) {
37
37
const base = import . meta. env . BASE_URL
38
38
pagePath =
39
- sanitizeFileName (
40
- pagePath . slice ( base . length ) . replace ( / \/ / g, '_' ) || 'index'
41
- ) + '.md'
39
+ ( pagePath . slice ( base . length ) . replace ( / \/ / g, '_' ) || 'index' ) + '.md'
42
40
// client production build needs to account for page hash, which is
43
41
// injected directly in the page's html
44
42
const pageHash = __VP_HASH_MAP__ [ pagePath . toLowerCase ( ) ]
45
43
pagePath = `${ base } assets/${ pagePath } .${ pageHash } .js`
46
44
} else {
47
45
// ssr build uses much simpler name mapping
48
- pagePath = `./${ sanitizeFileName (
49
- pagePath . slice ( 1 ) . replace ( / \/ / g, '_' )
50
- ) } .md.js`
46
+ pagePath = `./${ pagePath . slice ( 1 ) . replace ( / \/ / g, '_' ) } .md.js`
51
47
}
52
48
}
53
49
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import { slash } from '../utils/slash'
7
7
import { SiteConfig } from '../config'
8
8
import { APP_PATH } from '../alias'
9
9
import { createVitePressPlugin } from '../plugin'
10
- import { sanitizeFileName } from '../shared'
11
10
import { buildMPAClient } from './buildMPAClient'
12
11
13
12
export const okMark = '\x1b[32m✓\x1b[0m'
@@ -69,7 +68,6 @@ export async function bundle(
69
68
// other
70
69
preserveEntrySignatures : 'allow-extension' ,
71
70
output : {
72
- sanitizeFileName,
73
71
...rollupOptions ?. output ,
74
72
...( ssr
75
73
? {
Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ import {
10
10
createTitle ,
11
11
notFoundPageData ,
12
12
mergeHead ,
13
- EXTERNAL_URL_RE ,
14
- sanitizeFileName
13
+ EXTERNAL_URL_RE
15
14
} from '../shared'
16
15
import { slash } from '../utils/slash'
17
16
import { SiteConfig , resolveSiteDataByRoute } from '../config'
@@ -32,7 +31,7 @@ export async function renderPage(
32
31
// render page
33
32
const content = await render ( routePath )
34
33
35
- const pageName = sanitizeFileName ( page . replace ( / \/ / g, '_' ) )
34
+ const pageName = page . replace ( / \/ / g, '_' )
36
35
// server build doesn't need hash
37
36
const pageServerJsFileName = pageName + '.js'
38
37
// for any initial page load, we only need the lean version of the page js
Original file line number Diff line number Diff line change @@ -161,21 +161,3 @@ function hasTag(head: HeadConfig[], tag: HeadConfig) {
161
161
export function mergeHead ( prev : HeadConfig [ ] , curr : HeadConfig [ ] ) {
162
162
return [ ...prev . filter ( ( tagAttrs ) => ! hasTag ( curr , tagAttrs ) ) , ...curr ]
163
163
}
164
-
165
- // https://github.com/rollup/rollup/blob/fec513270c6ac350072425cc045db367656c623b/src/utils/sanitizeFileName.ts
166
-
167
- const INVALID_CHAR_REGEX = / [ \u0000 - \u001F " # $ & * + , : ; < = > ? [ \] ^ ` { | } \u007F ] / g
168
- const DRIVE_LETTER_REGEX = / ^ [ a - z ] : / i
169
-
170
- export function sanitizeFileName ( name : string ) : string {
171
- const match = DRIVE_LETTER_REGEX . exec ( name )
172
- const driveLetter = match ? match [ 0 ] : ''
173
-
174
- return (
175
- driveLetter +
176
- name
177
- . slice ( driveLetter . length )
178
- . replace ( INVALID_CHAR_REGEX , '_' )
179
- . replace ( / (?< = ^ | \/ ) _ + (? = [ ^ / ] * $ ) / , '' )
180
- )
181
- }
You can’t perform that action at this time.
0 commit comments