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

fix: patch requests are case-sensitive #66

Merged
merged 4 commits into from
Apr 29, 2022

Conversation

semoal
Copy link

@semoal semoal commented Apr 16, 2021

I've added a test to avoid a regression on this :)
Here it is @developit ;)

@semoal semoal mentioned this pull request Apr 16, 2021
@semoal
Copy link
Author

semoal commented Apr 25, 2021

@developit Ping on this Jason, don't want to add hurry just pinging to not forget =)

@lkmill
Copy link

lkmill commented Apr 30, 2021

any reason you are not uppercasing all http methods? even if they dont seem to break when lowercase i reckon they should be converted to uppercase both for consistency but more importantly the spec seems to recommend normalizing (converting to uppercase) all methods for backwards compatibility:

https://fetch.spec.whatwg.org/#methods

@semoal
Copy link
Author

semoal commented May 1, 2021

any reason you are not uppercasing all http methods? even if they dont seem to break when lowercase i reckon they should be converted to uppercase both for consistency but more importantly the spec seems to recommend normalizing (converting to uppercase) all methods for backwards compatibility:

https://fetch.spec.whatwg.org/#methods

Didn't know that ;) just fixing the wrong use case, but if normalizing is the correct approach I'll modify the PR later, thanks mate

@sirlancelot
Copy link
Contributor

sirlancelot commented Aug 5, 2021

In Google Chrome, patch specifically seemed to be causing problems. I'd been Googling for about an hour and finally came across this SO post: https://stackoverflow.com/a/67744766/51021

Apparently, some verbs (PATCH in my case) ARE case-sensitive when comparing against a pre-flight OPTIONS check.

I think in order to be the most compatible with the axios module, and to make PATCH work during cross-origin requests, these verbs should be made uppercase (See axios source: axios/lib/adapters/xhr.js#L32)

@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@developit
Copy link
Owner

From the size bot:

Size Change: +56 B (1%)

Total Size: 3.02 kB

Filename Size Change
dist/redaxios.js 990 B +18 B (1%)
dist/redaxios.module.js 990 B +19 B (1%)
dist/redaxios.umd.js 1.04 kB +19 B (1%)

compressed-size-action

@developit
Copy link
Owner

I might try checking if 'get'.toUpperCase() produces smaller sizes when minified.

@semoal semoal force-pushed the fix-patch-req branch 2 times, most recently from 774d095 to fddb4da Compare November 7, 2021 22:24
@semoal
Copy link
Author

semoal commented Nov 7, 2021

@googlebot I fixed it.

@semoal
Copy link
Author

semoal commented Nov 7, 2021

I might try checking if 'get'.toUpperCase() produces smaller sizes when minified.

Yep, I think so.

With uppercase:

Build "redaxios" to dist:
        949 B: redaxios.js.gz
        825 B: redaxios.js.br
        945 B: redaxios.module.js.gz
        823 B: redaxios.module.js.br
        997 B: redaxios.umd.js.gz
        871 B: redaxios.umd.js.br

Without uppercase

Build "redaxios" to dist:
        962 B: redaxios.js.gz
        821 B: redaxios.js.br
        958 B: redaxios.module.js.gz
        816 B: redaxios.module.js.br
       1009 B: redaxios.umd.js.gz
        868 B: redaxios.umd.js.br

Just pushed the change to test against the github workflow.

@matschik
Copy link

We just encountered the same problem and this PR would fix it 🥳
Is there anything blocking the merge ?

@developit developit linked an issue Apr 29, 2022 that may be closed by this pull request
src/index.js Outdated Show resolved Hide resolved
@developit
Copy link
Owner

Size Change: +34 B (1%)

Total Size: 2.99 kB

Filename Size Change
dist/redaxios.js 982 B +10 B (1%)
dist/redaxios.module.js 983 B +12 B (1%)
dist/redaxios.umd.js 1.03 kB +12 B (1%)

@developit developit merged commit cde69c5 into developit:master Apr 29, 2022
@semoal semoal deleted the fix-patch-req branch May 1, 2022 17:21
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.

lower case method?
6 participants