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

Support for the file protocol #81

Open
radarfox opened this issue Apr 5, 2019 · 0 comments
Open

Support for the file protocol #81

radarfox opened this issue Apr 5, 2019 · 0 comments
Labels

Comments

@radarfox
Copy link

radarfox commented Apr 5, 2019

Hello,

awesome project, helped a lot. Thanks! Only problem I found is that mocking URLs starting with file:// isn't working properly.

This doesn't work:

xhrMock.setup();
const url = 'file:///C:/web/index.html';
xhrMock.get(url , {body: '<html></html>'});
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();

It outputs this error:

ERROR: 'xhr-mock: No handler returned a response for the request.
GET file:/C:/web/index.html HTTP/1.1

So my current hotfix is this:

xhrMock.setup();
xhrMock.get('file:/C:/web/index.html', {body: '<html></html>'});
const xhr = new XMLHttpRequest();
xhr.open('GET', 'file:///C:/web/index.html', true);
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants