Skip to content

Commit

Permalink
fix ff invalid protocal
Browse files Browse the repository at this point in the history
  • Loading branch information
phonglk committed Feb 21, 2017
1 parent b9625c7 commit 1942f20
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/utils/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
import 'whatwg-fetch';
/* eslint-enable import/no-unresolved */

function patchProtocal(url) {
if (/^\/\//.test(url)) {
return url.replace(/^/, window.location.protocol);
}
return url;
}

function requestFactory(requestOption = {}) {
return (url, additionOption = {}) => new Promise((resolve, reject) => {
const options = { ...requestOption, ...additionOption };
fetch(url, options).then((response) => {
fetch(patchProtocal(url), options).then((response) => {
response.text().then(resolve).catch(reject);
}).catch((err) => {
reject(err);
Expand Down

0 comments on commit 1942f20

Please sign in to comment.