MCPcopy
hub / github.com/lukeautry/tsoa / normalisePath

Function normalisePath

packages/cli/src/utils/pathUtils.ts:7–21  ·  view source on GitHub ↗
(path: string, withPrefix?: string, withSuffix?: string, skipPrefixAndSuffixIfEmpty = true)

Source from the content-addressed store, hash-verified

5 * Replace ':pathParam' with '{pathParam}'
6 */
7export function normalisePath(path: string, withPrefix?: string, withSuffix?: string, skipPrefixAndSuffixIfEmpty = true) {
8 if ((!path || path === '/') && skipPrefixAndSuffixIfEmpty) {
9 return '';
10 }
11 if (!path || typeof path !== 'string') {
12 path = '' + path;
13 }
14 // normalise beginning and end of the path
15 let normalised = path.replace(/^[/\\\s]+|[/\\\s]+$/g, '');
16 normalised = withPrefix ? withPrefix + normalised : normalised;
17 normalised = withSuffix ? normalised + withSuffix : normalised;
18 // normalise / signs amount in all path
19 normalised = normalised.replace(/[/\\\s]+/g, '/');
20 return normalised;
21}
22
23export function convertColonPathParams(path: string) {
24 if (!path || typeof path !== 'string') {

Callers 6

buildServersMethod · 0.90
buildPathsMethod · 0.90
GetSpecMethod · 0.90
buildPathsMethod · 0.90
buildContextFunction · 0.90
paths.spec.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected