Created
September 12, 2018 23:57
-
-
Save nathan-lapinski/f98012cd952094b988153ea5a4cd321c to your computer and use it in GitHub Desktop.
An excerpt of the DefaultUrlMatching algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check each config part against the actual URL | |
for (let index = 0; index < parts.length; index++) { | |
const part = parts[index]; | |
const segment = segments[index]; | |
const isParameter = part.startsWith(':'); | |
if (isParameter) { | |
posParams[part.substring(1)] = segment; | |
} else if (part !== segment.path) { | |
// The actual URL part does not match the config, no match | |
return null; | |
} | |
} | |
return {consumed: segments.slice(0, parts.length), posParams}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment