(rootFolder: string, nestedFolder: string)
| 58 | * @returns Returns the number of levels between the two |
| 59 | */ |
| 60 | export const calculatePathDifference = (rootFolder: string, nestedFolder: string) => { |
| 61 | const rootParts = rootFolder.split("/"); |
| 62 | const nestedParts = nestedFolder.split("/"); |
| 63 | |
| 64 | let i = 0; |
| 65 | while (i < rootParts.length && i < nestedParts.length && rootParts[i] === nestedParts[i]) { |
| 66 | i++; |
| 67 | } |
| 68 | |
| 69 | const pathDifference = nestedParts.length - i; |
| 70 | return pathDifference; |
| 71 | }; |
| 72 | /** |
| 73 | * Returns the difference in two paths as a string |
| 74 | * @example "routes/something" and "routes/something/nested/path" would return "nested/path" |
no outgoing calls
no test coverage detected