Comments (1)
IMHO, this bug is just one aspect of a more general problem. The real XHR implementation normalizes all URL strings before the request is sent. Converting an empty path into a single slash is just one such normalization.
Likewise, default ports are stripped off, and the hostname part is normalized. For example, http://0177.0.0.1, http://0x7f.0.0.1, or http://0000177.0x0.0000.0x1 are different funny ways of writing http://127.0.0.1/, but a browser will treat them all in exactly the same manner. You can easily try it out by clicking the links.
So, why not just normalize all URLs for incoming requests with new URL(url).href
? That would fix all of these problems. But, of course, it would introduce a small incompatibility with previous versions.
See http://www.guido-flohr.net/the-gory-details-of-url-validation/ for more such details.
from xhr-mock.
Related Issues (20)
- Is there a method similar with fetchMock.flush? HOT 8
- Responsetype "arraybuffer" not implemented correctly
- Handler inside createMockFunction never gets triggered. HOT 1
- Simulating a timeout causes Jest to throw a ECONNREFUSED error but the tests pass HOT 1
- feat: support verbose log in dev mode? HOT 1
- Support params match?
- Jest passes but xhr-mock logs the Jest expectation failure to console.error
- Feature request for sending/setting cookies automatically when present.
- Is there a way to overwrite a request again?
- Request headers are not reset between .open() calls
- Unclear how to test upload progress HOT 1
- xhr.readyState = 2 // xhr.status = 0 HOT 1
- Examples for mocks set up using regular expressions HOT 1
- Add xhrMock.all method for all of get, post, put, patch, delete HOT 1
- Add url masks please HOT 2
- New release HOT 2
- sequence is not a function HOT 2
- Latest release doesn't published HOT 1
- Release latest changes to npm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xhr-mock.