Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error related to Router only returning the FIRST of many potential matches rather than the correct one. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thompsonlabs
Copy link

Modified routing logic to match against the longest possible potential match rather than just returning the first match, thereby ensuring matches that are merely a subset of the provided path are not erroneously returned as they were previously. Also added and wired up a new Route and corresponding View (PostViewCategories) to test the new routing logic.

…l match rather than just returning the first match, thereby ensuring matches that are merely a subset of the provided path are not erroneously returned as they were previously. Also added and wired up a new Route and corresponding View (PostViewCategories) to test the new routing logic.
@dcode-youtube
Copy link
Owner

Thanks for this suggestion. Sorry it took me over a year to reply to this PR.

I like it but can you please remove the PostViewCategories view because it's not part of the video.

Copy link
Contributor

@felix-d1strict felix-d1strict left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at the code and files for the PostViewCategories because the author of this repo doesn't want to merge those files anyway.

};
});

let match = potentialMatches.find(potentialMatch => potentialMatch.result !== null);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A (unnecessary) empty line. 😉


})


Copy link
Contributor

@felix-d1strict felix-d1strict Jul 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also an unnecessarily empty lines here.

Comment on lines +43 to +51
var match
potentialMatches.forEach(entry =>{

if(entry.result != null) {

match = (match === undefined || entry.route.path.length > match.route.path.length) ? entry : match
}

})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be looked at again more closely.
In addition to an = at the beginning, a semicolon is also missing at the end too.

There are also unnecessary empty lines here, again that can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants