silverwolf-x's picture
download
raw
864 Bytes
import type { PathnameNormalizer } from './pathname-normalizer'
import {
RSC_SEGMENT_SUFFIX,
RSC_SEGMENTS_DIR_SUFFIX,
} from '../../../lib/constants'
import { escapeStringRegexp } from '../../../shared/lib/escape-regexp'
const PATTERN = new RegExp(
`^(/.*)${escapeStringRegexp(RSC_SEGMENTS_DIR_SUFFIX)}(/.*)${escapeStringRegexp(RSC_SEGMENT_SUFFIX)}$`
)
export class SegmentPrefixRSCPathnameNormalizer implements PathnameNormalizer {
public match(pathname: string): boolean {
return PATTERN.test(pathname)
}
public extract(pathname: string) {
const match = pathname.match(PATTERN)
if (!match) return null
return { originalPathname: match[1], segmentPath: match[2] }
}
public normalize(pathname: string): string {
const match = this.extract(pathname)
if (!match) return pathname
return match.originalPathname
}
}

Xet Storage Details

Size:
864 Bytes
·
Xet hash:
1b81a980d7bcf986ccbac33d2cde25a99e4f6819653db1b83996faacf0ecd141

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.