-
Notifications
You must be signed in to change notification settings - Fork 26k
/
app-pathname-normalizer.ts
36 lines (32 loc) · 1.12 KB
/
app-pathname-normalizer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { normalizeAppPath } from '../../../../../shared/lib/router/utils/app-paths'
import { Normalizers } from '../../normalizers'
import { wrapNormalizerFn } from '../../wrap-normalizer-fn'
import { UnderscoreNormalizer } from '../../underscore-normalizer'
import { Normalizer } from '../../normalizer'
export class AppPathnameNormalizer extends Normalizers {
constructor() {
super([
// The pathname to match should have the trailing `/page` and other route
// group information stripped from it.
wrapNormalizerFn(normalizeAppPath),
// The page should have the `%5F` characters replaced with `_` characters.
new UnderscoreNormalizer(),
])
}
public normalize(page: string): string {
return super.normalize(page)
}
}
export class DevAppPathnameNormalizer extends Normalizers {
constructor(pageNormalizer: Normalizer) {
super([
// This should normalize the filename to a page.
pageNormalizer,
// Normalize the app page to a pathname.
new AppPathnameNormalizer(),
])
}
public normalize(filename: string): string {
return super.normalize(filename)
}
}