Skip to content

Instantly share code, notes, and snippets.

@nathan-lapinski
Created September 12, 2018 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathan-lapinski/f98012cd952094b988153ea5a4cd321c to your computer and use it in GitHub Desktop.
Save nathan-lapinski/f98012cd952094b988153ea5a4cd321c to your computer and use it in GitHub Desktop.
An excerpt of the DefaultUrlMatching algorithm
// 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