1 | const nodeFetch = require('node-fetch')
|
2 | const realFetch = nodeFetch.default || nodeFetch
|
3 |
|
4 | const fetch = function (url, options) {
|
5 | // Support schemaless URIs on the server for parity with the browser.
|
6 | // Ex: //github.com/ -> https://github.com/
|
7 | if (/^\/\//.test(url)) {
|
8 | url = 'https:' + url
|
9 | }
|
10 | return realFetch.call(this, url, options)
|
11 | }
|
12 |
|
13 | fetch.ponyfill = true
|
14 |
|
15 | module.exports = exports = fetch
|
16 | exports.fetch = fetch
|
17 | exports.Headers = nodeFetch.Headers
|
18 | exports.Request = nodeFetch.Request
|
19 | exports.Response = nodeFetch.Response
|
20 |
|
21 | // Needed for TypeScript consumers without esModuleInterop.
|
22 | exports.default = fetch
|