Skip to content
Open
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
68 changes: 31 additions & 37 deletions json-stream.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
import Oboe from './lib/oboe-browser.min.js'
import XMLHttpRequest from './polyfill/XMLHttpRequest'
import URIUtil from './utils/uri'
import Oboe from "oboe";
import XMLHttpRequest from "./polyfill/XMLHttpRequest";
import URIUtil from "./utils/uri";

const OboeExtended = (arg: string | Object) => {
window.location = "";

if (!window.XMLHttpRequest.isRNFBPolyfill) {
window.XMLHttpRequest = XMLHttpRequest;
console.warn(
"Use JSONStream will automatically replace window.XMLHttpRequest with RNFetchBlob.polyfill.XMLHttpRequest. " +
"You are seeing this warning because you did not replace it manually."
);
}

window.location = ''
if (typeof arg === "string") {
if (URIUtil.isFileURI(arg)) {
arg = {
url: "JSONStream://" + arg,
headers: { noCache: true },
};
} else arg = "JSONStream://" + arg;
} else if (typeof arg === "object") {
let headers = arg.headers || {};
if (URIUtil.isFileURI(arg.url)) {
headers.noCache = true;
}
arg = Object.assign(arg, {
url: "JSONStream://" + arg.url,
headers,
});
}
return Oboe(arg);
};

if(!window.XMLHttpRequest.isRNFBPolyfill ) {
window.XMLHttpRequest = XMLHttpRequest
console.warn(
'Use JSONStream will automatically replace window.XMLHttpRequest with RNFetchBlob.polyfill.XMLHttpRequest. ' +
'You are seeing this warning because you did not replace it manually.'
)
}

if(typeof arg === 'string') {
if(URIUtil.isFileURI(arg)) {
arg = {
url : 'JSONStream://' + arg,
headers : { noCache : true }
}
}
else
arg = 'JSONStream://' + arg

}
else if(typeof arg === 'object') {
let headers = arg.headers || {}
if(URIUtil.isFileURI(arg.url)) {
headers.noCache = true
}
arg = Object.assign(arg, {
url : 'JSONStream://' + arg.url,
headers
})
}
return Oboe(arg)
}

export default OboeExtended
export default OboeExtended;
Loading