| 98 | } |
| 99 | |
| 100 | function rankMatch(pathname: string, query: string): number { |
| 101 | if (!query) return 0 |
| 102 | const lowerPath = pathname.toLowerCase() |
| 103 | const lowerQuery = query.toLowerCase() |
| 104 | const index = lowerPath.indexOf(lowerQuery) |
| 105 | if (index >= 0) return index |
| 106 | let queryIndex = 0 |
| 107 | for (const char of lowerPath) { |
| 108 | if (char === lowerQuery[queryIndex]) queryIndex += 1 |
| 109 | if (queryIndex === lowerQuery.length) return lowerPath.length |
| 110 | } |
| 111 | return Number.POSITIVE_INFINITY |
| 112 | } |
| 113 | |
| 114 | export function createRuntimeNodeLocalFilesAdapter(): RuntimeNodeFilesAdapter { |
| 115 | return { |