Debian Codegraph @

tests/support/utils.ts

raw
1 /**
2 * Trim slashes from a string
3 * @see https://stackoverflow.com/a/3840645/586823
4 */
5 const trimSlashes = (str: string) => str.replace(/^\/|\/$/g, '');
6
7 /**
8 * Create a function to prefix a path
9 */
10 export const prefixed = (prefix: string) => {
11 return (path: string) => `/${trimSlashes(prefix)}/${trimSlashes(path)}`;
12 };