File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,16 @@ describe("utils", () => {
155155 expect ( fetchSuccess ) . toBeInstanceOf ( Object )
156156 } )
157157
158+ it ( "fetchLite: access to a private NPM Registry without auth token" , async ( ) => {
159+ expect . assertions ( 1 )
160+
161+ const fetchSuccess = await fetchLite < { error : string } > (
162+ "https://registry.npmjs.org/@fortawesome/pro-light-svg-icons"
163+ )
164+
165+ expect ( fetchSuccess ?. error ) . toBe ( "Not found" )
166+ } )
167+
158168 it ( "fetchLite: invalid URL" , async ( ) => {
159169 expect . assertions ( 1 )
160170
Original file line number Diff line number Diff line change @@ -140,6 +140,10 @@ export const fetchLite = <T>(
140140 // istanbul ignore next
141141 response . on ( "error" , ( ) => resolve ( undefined ) )
142142 response . on ( "end" , ( ) => {
143+ if ( ! response . headers [ "content-encoding" ] ) {
144+ return resolve ( JSON . parse ( responseBuffers . toString ( ) ) )
145+ }
146+
143147 return zlib . gunzip (
144148 Buffer . concat ( responseBuffers ) ,
145149 ( _error , contents ) => {
You can’t perform that action at this time.
0 commit comments