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

Unexpected 'Unsupported protocol' error for relative URLs containing colon (:) character #4633

Closed
cduff opened this issue Apr 26, 2022 · 4 comments · Fixed by #4639
Closed

Comments

@cduff
Copy link

cduff commented Apr 26, 2022

Describe the bug

For some REST API endpoints we use Google Cloud API Custom Methods URL design like /api/resource:customVerb.

These worked with axios prior to 0.27.1 but now they result in an error like:

AxiosError { message: "Unsupported protocol /api/resource:', code: "ERR_BAD_REQUEST", ... }

To Reproduce

Try to have axios get a relative URL with a colon in it, e.g.

axios.get("/api/resource:customVerb");

Expected behavior

Should continue working as it did before version 0.27.1.

Environment

  • Axios Version: 0.27.1
  • Browser: Microsoft Edge 100.0.1185.50
  • Node.js Version: 16.14.2
  • OS: Windows 10 Pro

Additional context/Screenshots

n/a

@philBrown
Copy link

philBrown commented Apr 27, 2022

Nothing to do with Axios. The colon needs to be encoded...

axios.get("/api/resource%3AcustomVerb")

@cduff
Copy link
Author

cduff commented Apr 27, 2022

Nothing to do with Axios. The colon needs to be encoded...

axios.get("/api/resource%3AcustomVerb")

@philBrown Are you sure? Source?

I'm not intimately familiar with the standards in play for this but the following suggest it is valid without encoding:

@philBrown
Copy link

philBrown commented Apr 27, 2022

@cduff My mistake, this is an Axios-specific problem. Encoding the colon is a valid work-around though

@gomgomshrimp
Copy link

gomgomshrimp commented Apr 27, 2022

I have the same issue with Axios version 0.27.1.
To work properly, use the previous version.
<script src="https://unpkg.com/axios@0.26.1/dist/axios.min.js"></script>

jasonsaayman added a commit that referenced this issue Apr 27, 2022
Added unit tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
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 a pull request may close this issue.

3 participants