(to: string | undefined)
| 900 | } |
| 901 | |
| 902 | const parsePathname = (to: string | undefined) => { |
| 903 | let cursor = 0 |
| 904 | let data |
| 905 | const path = to ?? '' |
| 906 | const segments: Array<PathSegment> = [] |
| 907 | while (cursor < path.length) { |
| 908 | const start = cursor |
| 909 | data = parseSegment(path, start, data) |
| 910 | const end = data[5] |
| 911 | cursor = end + 1 |
| 912 | const type = data[0] |
| 913 | const value = path.substring(data[2], data[3]) |
| 914 | const prefix = path.substring(start, data[1]) |
| 915 | const suffix = path.substring(data[4], end) |
| 916 | const segment: PathSegment = { |
| 917 | type, |
| 918 | value, |
| 919 | } |
| 920 | if (prefix) { |
| 921 | segment.prefixSegment = prefix |
| 922 | } |
| 923 | if (suffix) { |
| 924 | segment.suffixSegment = suffix |
| 925 | } |
| 926 | segments.push(segment) |
| 927 | } |
| 928 | return segments |
| 929 | } |
| 930 | |
| 931 | describe('regular usage', () => { |
| 932 | it.each([ |
no test coverage detected