silverwolf-x/project / packages /next /src /server /normalizers /absolute-filename-normalizer.ts
silverwolf-x's picture
download
raw
1.01 kB
import type { PAGE_TYPES } from '../../lib/page-types'
import { absolutePathToPage } from '../../shared/lib/page-path/absolute-path-to-page'
import type { Normalizer } from './normalizer'
/**
* Normalizes a given filename so that it's relative to the provided directory.
* It will also strip the extension (if provided) and the trailing `/index`.
*/
export class AbsoluteFilenameNormalizer implements Normalizer {
/**
*
* @param dir the directory for which the files should be made relative to
* @param extensions the extensions the file could have
* @param keepIndex when `true` the trailing `/index` is _not_ removed
*/
constructor(
private readonly dir: string,
private readonly extensions: ReadonlyArray<string>,
private readonly pagesType: PAGE_TYPES
) {}
public normalize(filename: string): string {
return absolutePathToPage(filename, {
extensions: this.extensions,
keepIndex: false,
dir: this.dir,
pagesType: this.pagesType,
})
}
}

Xet Storage Details

Size:
1.01 kB
·
Xet hash:
27d12390c52801dc0ee227ad5ee359cd2ecb7d30f16a6e9e25e49bf7d9eebc9f

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