rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
43 lines (42 loc) • 1.05 kB
TypeScript
import ValueCollection from "./valueCollection";
import { HTTPMethods } from "../types/external";
type Segment = {
raw: string;
paramsRegExp: RegExp;
params: string[];
};
type Data = {
type: 'regexp';
value: RegExp;
prefix: string;
segments: Segment[];
} | {
type: 'normal';
value: string;
segments: Segment[];
};
/**
* A Utility to make checking paths safer
* @since 8.4.0
*/ export default class Path {
method: HTTPMethods;
path: string | RegExp;
data: Data;
/**
* Create a new Path object
* @since 8.4.0
*/ constructor(method: HTTPMethods, path: string | RegExp);
/**
* Add a Prefix to the Path
* @since 8.4.0
*/ addPrefix(prefix: string): this;
/**
* Add a Suffix to the Path
* @since 8.4.0
*/ addSuffix(prefix: string): this;
/**
* Test the Path against the Request Path
* @since 8.4.0
*/ matches(method: HTTPMethods, collection: ValueCollection, requestPath: string, requestPathSplit: string[]): boolean;
}
export {};