Skip to content
Permalink
Browse files

Fix: Use <base> element to resolve the url

  • Loading branch information...
sarvaje authored and antross committed Aug 21, 2019
1 parent c5a6c4a commit 6b26a320a7777090a6ef82901d073c131d9672ec
@@ -1,9 +1,6 @@
/**
* @fileoverview Check for correct usage of `apple-touch-icon`.
*/

import { URL } from 'url';

import * as getImageData from 'image-size';

import { debug as d, misc, network } from '@hint/utils';
@@ -102,7 +99,7 @@ export default class AppleTouchIconsHint implements IHint {
* to figure out the full URL of the `apple-touch-icon`.
*/

const appleTouchIconURL = new URL(appleTouchIconHref, resource).href;
const appleTouchIconURL = appleTouchIcon.resolveUrl(appleTouchIconHref);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@@ -1,5 +1,3 @@
import { URL } from 'url';

import {
ElementFound,
FetchEnd,
@@ -78,7 +76,7 @@ export default class ManifestParser extends Parser<ManifestEvents> {

// Try to fetch the web app manifest.

const manifestURL: string = (new URL(hrefValue, resource)).href;
const manifestURL: string = element.resolveUrl(hrefValue);

await this.engine.emitAsync(this.fetchStartEventName, { resource });

@@ -20,7 +20,10 @@ const getElementLinkEventValue = (relAttribute: string = 'manifest', hrefAttribu

return relAttribute;
},
nodeName: 'LINK'
nodeName: 'LINK',
resolveUrl: (value: string) => {
return value;
}
},
resource: 'https://example.com'
};
@@ -538,7 +538,7 @@ export class Connector implements IConnector {

try {
debug(`resource ${href} to be fetched`);
const fullFaviconUrl = this._finalHref + href.substr(1);
const fullFaviconUrl = dom.resolveUrl(href);

await this._server.emitAsync('fetch::start', { resource: fullFaviconUrl });

0 comments on commit 6b26a32

Please sign in to comment.
You can’t perform that action at this time.