question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some use-cases may require allowing an empty URL

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’d like to give some feedback for the axios 0.25 release. #3791 introduces a fast failure when an empty string is provided as a URL to the request builder. However, my own and at least one other project are intentionally using empty strings as URLs and the 0.25 release breaks working code. It is listed as a breaking change in the changelog, but the behavior may be unpractical for some use-cases: Let’s imagine a service abstraction over a RESTful resource; the baseURL could be something like http://example.com/examples, avoiding passing /examples as a path with each request. A GET or POST request using "" as a URL would be valid in this case.

Describe the solution you’d like

  • Is it possible for the request builder to accept empty strings but fail for undefined?
  • Or maybe some config option could be introduced to intentionally opt out of the fast failure.
  • An obscure solution would be to additionally pass the baseURL as url to axios.create, but currently the presence of the URL is checked before merging the configs. Moving the if (!config.url) { part down after the config merge would allow this escape hatch.

I’d be happy to submit a PR if desired.

Describe alternatives you’ve considered

  • Changing the respective occurrences in my code.
  • Using a slash or a space as a URL would work in many cases but it would also introduce trailing slashes.

Additional context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:33
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
jasonsaaymancommented, Jan 26, 2022

We could potentially change the name to path, then make it not required, then this might make more sense, people can then implement baseUrl and leave out path. Does this sound like a better solution?

We can also use a mapper to allow some backward compatibility with url to start off with and then add warnings and remove.

8reactions
jasonsaaymancommented, Jan 27, 2022

Changes made with #4426 will release soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it a good practice to use an empty URL for a HTML form's ...
@Kerrick Yes, I believe HTML5 allows omitting the action attribute entirely, and defaults it to empty string. HTML4 did not, it specifies action...
Read more >
Using presigned URLs - Amazon Simple Storage Service
Use a presigned URL to share or upload objects in Amazon S3 without requiring AWS security credentials or permissions.
Read more >
<input type="url"> - HTML: HyperText Markup Language | MDN
The input value is automatically validated to ensure that it's either empty or a properly-formatted URL before the form can be submitted.
Read more >
Referer and Referrer-Policy best practices - web.dev
All policies that take the scheme (HTTPS vs. HTTP) into account ( strict-origin , no-referrer-when-downgrade and strict-origin-when-cross- ...
Read more >
Tag your Google Ads final URLs - Analytics Help
Special cases · Your website doesn't allow arbitrary URL parameters · You need to use auto-tagging for non-Analytics purposes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found