fix: strip off hash from request urls

This commit is contained in:
Yury Semikhatsky 2019-12-18 16:23:43 -08:00
parent ac2ea265fe
commit 0f696d4cfe
2 changed files with 11 additions and 2 deletions

View file

@ -67,6 +67,15 @@ export function rewriteCookies(cookies: SetNetworkCookieParam[]): SetNetworkCook
});
}
function stripFragmentFromUrl(url: string): string
{
if (!url.indexOf('#'))
return url;
const parsed = new URL(url);
parsed.hash = '';
return parsed.href;
}
export type Headers = { [key: string]: string };
export class Request {
@ -94,7 +103,7 @@ export class Request {
for (const request of redirectChain)
request._finalRequest = this;
this._documentId = documentId;
this._url = url;
this._url = stripFragmentFromUrl(url);
this._resourceType = resourceType;
this._method = method;
this._postData = postData;

View file

@ -392,7 +392,7 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
expect(requests.length).toBe(1);
expect(requests[0].url()).toBe(dataURL);
});
it.skip(FFOX || WEBKIT)('should navigate to URL with hash and fire requests without hash', async({page, server}) => {
it('should navigate to URL with hash and fire requests without hash', async({page, server}) => {
const requests = [];
page.on('request', request => !utils.isFavicon(request) && requests.push(request));
const response = await page.goto(server.EMPTY_PAGE + '#hash');