feross / simple-get

Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines
MIT License
401 stars 50 forks source link

Added a redirect history #24

Closed stevenvachon closed 7 years ago

stevenvachon commented 7 years ago

fixes #23

stevenvachon commented 7 years ago

@feross

Flet commented 7 years ago

Some code golf to get <100 :)

-      if (opts.maxRedirects > 0) {
-        opts.redirectHistory.push(res)
-        simpleGet(opts, cb)
-      } else {
-        cb(new Error('too many redirects'))
-      }
+      if (opts.maxRedirects < 1) return cb(new Error('too many redirects'))
+      opts.redirectHistory.push(res)
+      simpleGet(opts, cb)