mirror of https://github.com/swup/swup.git
13 lines
325 B
TypeScript
13 lines
325 B
TypeScript
/**
|
|
* Trim slashes from a string
|
|
* @see https://stackoverflow.com/a/3840645/586823
|
|
*/
|
|
const trimSlashes = (str: string) => str.replace(/^\/|\/$/g, '');
|
|
|
|
/**
|
|
* Create a function to prefix a path
|
|
*/
|
|
export const prefixed = (prefix: string) => {
|
|
return (path: string) => `/${trimSlashes(prefix)}/${trimSlashes(path)}`;
|
|
};
|