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

feat!: Matches required query parameters #21

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jphastings
Copy link

@jphastings jphastings commented Jul 9, 2023

Code now Parses and MatchAndExpandPlaceholders for query parameters as well as paths. I ended up implementing #20 without waiting for a discussion on the issue, for which I apologise! I'll be happy to rewrite without a review if there are concerns with the proposal.

Placeholders are shared between the two.

/things type=photos /photos.html 200
/things type=       /invalid-thing-type.html 400
/things type=:thing /thing-:thing.html 200
/things             /things.html 200

This is a breaking change for the package's API (though not for the _redirects file format), as the query params need to be passed into MatchAndExpandPlaceholders. I'll be un-drafting ipfs/boxo#406 (which adapts syntax to include this work), once (if!) this PR is merged, so go.mod/go.sum can be corrected.

This commit also codifies in tests some of the previously implicit edge cases, particularly around duplicate placeholders.

Closes #20


If you build a copy of ipfs with this in (via ipfs/boxo#406) then you can visit this CID locally and see this in action.

jphastings added a commit to jphastings/boxo that referenced this pull request Jul 9, 2023
Draft commit for using ipfs/go-ipfs-redirects-file#21 to allow query parameters in redirects.

Cannot be completed/will not be ready until that PR is merged, and a new version released (so go.mod/go.sum can be updated here)
jphastings added a commit to jphastings/boxo that referenced this pull request Jul 9, 2023
Draft commit for using ipfs/go-ipfs-redirects-file#21 to allow query parameters in redirects.

Cannot be completed/will not be ready until that PR is merged, and a new version released (so go.mod/go.sum can be updated here)
@jphastings jphastings force-pushed the query-params branch 2 times, most recently from efc53cb to 17de3f8 Compare July 9, 2023 07:14
"/fixed-val val=val /to 200\n/dynamic-val val=:val /to/:val 301\n/empty-val val= /to 404\n/any-val val /to 302\n",
"/multi-query val1=val1 val2=:val2 val3= val4 /to/:val2\n/multi-query2 val1=val1 val2=:val2 val3= val4 /to/:val2 302\n",
"/bad-syntax1 val=a&val=b /to\n", "/bad-syntax2 val=a&val2=b /to 302\n", "/a ^&notparams /b\n", "/bad-status type=:type /to 3oo\n", "/bad-chars :type=whatever /to\n", "/bad-chars type=what:ever /to\n",
}
Copy link
Author

Choose a reason for hiding this comment

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

I wasn't 100% clear on the fuzz testing strategy here, I'd appreciate a closer look at whether I've chosen suitable testcases here.

Code now parses and `MatchAndExpandPlaceholders` for query parameters as
well as paths.

Placeholders are shared between the two.

This commit codifies some of the previously implicit edgecases,
particularly around duplicate placeholders.

Closes ipfs#20
@lidel lidel marked this pull request as draft November 9, 2023 20:37
@lidel
Copy link
Member

lidel commented Nov 9, 2023

(turning to a draft until we have an IPIP mentioned in #20)

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.

Support Query Parameters?
2 participants