Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/request / src / deps / polyfill.ts
Size: Mime:
import { URL, URLSearchParams } from 'url'
import realFetch from 'node-fetch'

const REALM = global as any

// this was in universal-fetch, not sure it is needed
// function mockFetch(
//   this: typeof realFetch,
//   url: Request | string,
//   options: any
// ) {
//   // add https if it is `//`
//   const finalUrl =
//     typeof url === 'string' && /^\/\//.test(url) ? 'https:' + url : url
//   // validate when using url direct
//   // otherwise node-fetch will validate
//   if (typeof finalUrl === 'string' && finalUrl.startsWith('http') === false) {
//     throw new TypeError('Only absolute URLs are supported: ' + url)
//   }
//   return realFetch.call(this, finalUrl, options)
// }

// set on global
if (!global.fetch) {
  global.fetch = realFetch
  global.Response = realFetch.Response
  global.Headers = realFetch.Headers
  global.Request = realFetch.Request
}
if (!global.URL) {
  global.URL = URL
}
if (!global.URLSearchParams) {
  global.URLSearchParams = URLSearchParams
}