Comparing version 0.2.5 to 0.2.6
@@ -202,3 +202,3 @@ 'use strict'; | ||
const status = '' + headers[HTTP2_HEADER_STATUS]; | ||
const location = '' + headers[HTTP2_HEADER_LOCATION]; | ||
const location = utils_1.parseLocation(headers[HTTP2_HEADER_LOCATION], url); | ||
const isRedirected = isRedirectStatus[status]; | ||
@@ -205,0 +205,0 @@ if (headers[HTTP2_HEADER_SET_COOKIE]) { |
@@ -1,1 +0,1 @@ | ||
export declare const version = "0.2.5"; | ||
export declare const version = "0.2.6"; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = '0.2.5'; | ||
exports.version = '0.2.6'; | ||
//# sourceMappingURL=version.js.map |
export declare function arrayify<T>(value: T | Array<T>): Array<T>; | ||
export declare function arrayify<T>(value: Readonly<T> | ReadonlyArray<T>): Array<T>; | ||
export declare function parseLocation(location: string, origin: string): string; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url_1 = require("url"); | ||
function arrayify(value) { | ||
@@ -7,2 +8,9 @@ return Array.isArray(value) ? value : [value]; | ||
exports.arrayify = arrayify; | ||
function parseLocation(location, origin) { | ||
if ('string' !== typeof location) | ||
return null; | ||
const url = new url_1.URL(location, origin); | ||
return url.href; | ||
} | ||
exports.parseLocation = parseLocation; | ||
//# sourceMappingURL=utils.js.map |
@@ -75,3 +75,10 @@ 'use strict'; | ||
}); | ||
it('should handle (and follow) relative paths', async () => { | ||
const { fetch, disconnectAll } = _1.context(); | ||
const response = await fetch('https://nghttp2.org/httpbin/relative-redirect/2', { redirect: 'follow' }); | ||
chai_1.expect(response.url).to.equal("https://nghttp2.org/httpbin/get"); | ||
await response.text(); | ||
await disconnectAll(); | ||
}); | ||
}); | ||
//# sourceMappingURL=nghttp2.org.js.map |
@@ -9,3 +9,3 @@ 'use strict' | ||
import { arrayify } from './utils' | ||
import { arrayify, parseLocation } from './utils' | ||
import { | ||
@@ -338,3 +338,6 @@ Method, | ||
const status = '' + headers[ HTTP2_HEADER_STATUS ]; | ||
const location = '' + headers[ HTTP2_HEADER_LOCATION ]; | ||
const location = parseLocation( | ||
headers[ HTTP2_HEADER_LOCATION ], | ||
url | ||
); | ||
@@ -341,0 +344,0 @@ const isRedirected = isRedirectStatus[ status ]; |
'use strict' | ||
export const version = '0.2.5'; | ||
export const version = '0.2.6'; |
'use strict' | ||
import { URL } from 'url' | ||
import { Try } from 'already' | ||
@@ -12,1 +13,10 @@ | ||
} | ||
export function parseLocation( location: string, origin: string ) | ||
{ | ||
if ( 'string' !== typeof location ) | ||
return null; | ||
const url = new URL( location, origin ); | ||
return url.href; | ||
} |
{ | ||
"name": "fetch-h2", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "HTTP/2-only Fetch API client for Node.js", | ||
@@ -5,0 +5,0 @@ "author": "Gustaf Räntilä", |
@@ -118,3 +118,3 @@ 'use strict'; | ||
'https://nghttp2.org/httpbin/cookies/set?foo=bar', | ||
{ redirect:'manual' } ); | ||
{ redirect: 'manual' } ); | ||
@@ -131,3 +131,16 @@ expect( responseSet.headers.has( 'location' ) ).to.be.true; | ||
} ); | ||
it( 'should handle (and follow) relative paths', async ( ) => | ||
{ | ||
const { fetch, disconnectAll } = context( ); | ||
const response = await fetch( | ||
'https://nghttp2.org/httpbin/relative-redirect/2', | ||
{ redirect: 'follow' } ); | ||
expect( response.url ).to.equal( "https://nghttp2.org/httpbin/get" ); | ||
await response.text( ); | ||
await disconnectAll( ); | ||
} ); | ||
} ); | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3130543
6385
23