Skip to content

Commit

Permalink
fix #909: strip query from path along with hash
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein committed Jan 9, 2020
1 parent f5f92b0 commit 06f1071
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pages/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function Documentation({ item, headings, markdown, errorCode }) {
}

Documentation.getInitialProps = async ({ asPath, req }) => {
const item = getItemByPath(asPath.split('#')[0])
const item = getItemByPath(asPath.split('#')[0].split('?')[0])

if (!item) {
return {
Expand Down

3 comments on commit 06f1071

@jorgeorpinel
Copy link
Contributor

Choose a reason for hiding this comment

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

This works perfectly but should we add the ? check first? Query is supposed to come before hash, at least according to https://nodejs.org/api/url.html#url_url_strings_and_url_objects.

We could also use just .split(/[?#]/)[0] instead πŸ™‚

@shcheklein
Copy link
Member Author

Choose a reason for hiding this comment

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

This works perfectly but should we add the ? check first?

I think it does not matter in this case :)

split(/[?#]/)[0]

yep, we can do that

@jorgeorpinel
Copy link
Contributor

Choose a reason for hiding this comment

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

ok will do in a future regular updates pr, thanks!

Please sign in to comment.