mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 01:52:22 +00:00
15 lines
436 B
TypeScript
15 lines
436 B
TypeScript
export const removeTrailingSlash = (str: string) => {
|
|
if (str === "/") return str;
|
|
|
|
return str.endsWith("/") ? str.slice(0, -1) : str;
|
|
};
|
|
|
|
export const isValidPath = (val: string): boolean => {
|
|
if (val.length === 0) return false;
|
|
if (val === "/") return true;
|
|
|
|
// Check for valid characters and no consecutive slashes
|
|
const validPathRegex = /^[a-zA-Z0-9-_.:]+(?:\/[a-zA-Z0-9-_.:]+)*$/;
|
|
return validPathRegex.test(val);
|
|
};
|