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 Error when fetch used with data-url (related to DevExpress/testcafe#2865) #1766

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/client/sandbox/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export default class FetchSandbox extends SandboxBase {
requestMode = args[0].mode;
}
else {
url = parseProxyUrl(args[0]).destUrl;
const parsedProxyUrl = parseProxyUrl(args[0]);

url = parsedProxyUrl ? parsedProxyUrl.destUrl : args[0];
requestMode = (args[1] || {}).mode;
}

Expand Down
12 changes: 11 additions & 1 deletion test/client/fixtures/sandbox/fetch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ if (window.fetch) {
});
});

test('should not dublicate values of internal headers (GH-1360)', function () {
test('should not duplicate values of internal headers (GH-1360)', function () {
var reqInit = {
credentials: 'same-origin',
headers: new Headers({
Expand Down Expand Up @@ -606,6 +606,16 @@ if (window.fetch) {
ok(true);
});
});

test('should not throw an error when a data-url is used (GH-TC-2865)', function () {
return fetch('data:text/plain,foo')
.then(function (res) {
return res.text();
})
.then(function (body) {
strictEqual(body, 'foo');
});
});
});
}

Expand Down