silverwolf-x's picture
download
raw
896 Bytes
import { ParsedUrlQuery } from "querystring";
import * as plugins from "temp/extract-path-plugins";
export interface Plugin {
/**
* A function which will be called during path extraction
*/
exec(path: string): string;
}
export class PathExtractor {
/**
* Extract normalized Sitecore item path
* @param {ParsedUrlQuery} [params]
*/
public extract(params: ParsedUrlQuery | undefined): string {
if (params === undefined) {
return "/";
}
let path = Array.isArray(params.path)
? params.path.join("/")
: (params.path ?? "/");
// Ensure leading '/'
if (!path.startsWith("/")) {
path = "/" + path;
}
const extractedPath = (Object.values(plugins) as Plugin[]).reduce(
(resultPath, plugin) => plugin.exec(resultPath),
path,
);
return extractedPath;
}
}
export const pathExtractor = new PathExtractor();

Xet Storage Details

Size:
896 Bytes
·
Xet hash:
9ff553c9bb9c13947a103b178ef6cac539d58bfe60f875efdfc8e589a294b1c2

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