| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export const normalizeFullPath = (path?: string | null): string | null => { |
| if (!path) { |
| return null; |
| } |
| const trimmed = path.trim(); |
| if (!trimmed) { |
| return null; |
| } |
| const withLeadingSlash = trimmed.startsWith('/') ? trimmed : `/${trimmed}`; |
| const normalized = withLeadingSlash.replace(/\/{2,}/g, '/'); |
| return normalized.length > 1 && normalized.endsWith('/') ? normalized.slice(0, -1) : normalized; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export const normalizeDemoPath = (path: string): string => { |
| let normalized = path.trim(); |
| |
| if (normalized.startsWith('/')) { |
| normalized = normalized.substring(1); |
| } |
| |
| if (!normalized.endsWith('.json')) { |
| normalized += '.json'; |
| } |
| return normalized; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export const getDemoName = (path: string): string => { |
| const normalized = normalizeDemoPath(path); |
| |
| const fileName = normalized.replace(/\.json$/, ''); |
| |
| const parts = fileName.split('/'); |
| return parts[parts.length - 1]; |
| }; |
|
|
|
|