@applitools/ufg-client
Advanced tools
Comparing version 1.6.0 to 1.7.0
# Changelog | ||
## [1.7.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ufg-client@1.6.0...js/ufg-client@1.7.0) (2023-08-08) | ||
### Features | ||
* allow providing custom headers for resource fetching ([#1852](https://github.com/applitools/eyes.sdk.javascript1/issues/1852)) ([372cb96](https://github.com/applitools/eyes.sdk.javascript1/commit/372cb96b905a0661c36e2fa10a7855208fb55bb0)) | ||
## [1.6.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ufg-client@1.5.3...js/ufg-client@1.6.0) (2023-08-03) | ||
@@ -4,0 +11,0 @@ |
@@ -70,3 +70,6 @@ "use strict"; | ||
]), | ||
settings: { referer: utils.types.has(snapshot, 'url') ? snapshot.url : undefined, ...settings }, | ||
settings: { | ||
...settings, | ||
headers: { ...settings === null || settings === void 0 ? void 0 : settings.headers, Referer: utils.types.has(snapshot, 'url') ? snapshot.url : undefined }, | ||
}, | ||
logger, | ||
@@ -73,0 +76,0 @@ }), |
@@ -47,3 +47,3 @@ "use strict"; | ||
async function fetchResource({ resource, settings = {}, logger = mainLogger, }) { | ||
var _a; | ||
var _a, _b; | ||
logger = logger.extend(mainLogger, { tags: [`fetch-resource-${utils.general.shortid()}`] }); | ||
@@ -55,5 +55,5 @@ let runningRequest = cache.get(resource.id); | ||
headers: { | ||
Referer: settings.referer, | ||
Cookie: settings.cookies && (0, create_cookie_header_1.createCookieHeader)({ url: resource.url, cookies: settings.cookies }), | ||
'User-Agent': (_a = (resource.renderer && (0, create_user_agent_header_1.createUserAgentHeader)({ renderer: resource.renderer }))) !== null && _a !== void 0 ? _a : settings.userAgent, | ||
...settings.headers, | ||
'User-Agent': (_a = (resource.renderer && (0, create_user_agent_header_1.createUserAgentHeader)({ renderer: resource.renderer }))) !== null && _a !== void 0 ? _a : (_b = settings.headers) === null || _b === void 0 ? void 0 : _b['User-Agent'], | ||
}, | ||
@@ -60,0 +60,0 @@ proxy: resourceUrl => { |
@@ -74,2 +74,3 @@ "use strict"; | ||
async function processUrlResource({ resource, settings, logger = mainLogger, }) { | ||
var _a; | ||
const cachedResource = cache.get(resource.id); | ||
@@ -85,3 +86,7 @@ if (cachedResource) { | ||
if (utils.types.has(fetchedResource, 'value')) { | ||
const dependencies = await extractDependencyUrls({ resource: fetchedResource, settings, logger }); | ||
const dependencies = await extractDependencyUrls({ | ||
resource: fetchedResource, | ||
settings: { sourceUrl: (_a = settings === null || settings === void 0 ? void 0 : settings.headers) === null || _a === void 0 ? void 0 : _a.Referer }, | ||
logger, | ||
}); | ||
logger.log(`dependencyUrls for ${resource.url} --> ${dependencies}`); | ||
@@ -149,3 +154,3 @@ fetchedResource.dependencies = dependencies; | ||
resourceUrl: resource.url, | ||
pageUrl: settings === null || settings === void 0 ? void 0 : settings.referer, | ||
sourceUrl: settings === null || settings === void 0 ? void 0 : settings.sourceUrl, | ||
}); | ||
@@ -156,3 +161,3 @@ } | ||
resourceUrl: resource.url, | ||
pageUrl: settings === null || settings === void 0 ? void 0 : settings.referer, | ||
sourceUrl: settings === null || settings === void 0 ? void 0 : settings.sourceUrl, | ||
}); | ||
@@ -159,0 +164,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
const utils = __importStar(require("@applitools/utils")); | ||
function extractCssDependencyUrls(css, { resourceUrl, pageUrl }) { | ||
function extractCssDependencyUrls(css, { resourceUrl, sourceUrl }) { | ||
const urls = new Set(); | ||
@@ -44,3 +44,3 @@ const ast = csstree.parse(css, { | ||
else if (node.type === 'Declaration' && node.property.startsWith('--')) { | ||
return processCustomPropertyValue(node.value, { baseUrl: pageUrl !== null && pageUrl !== void 0 ? pageUrl : resourceUrl }); | ||
return processCustomPropertyValue(node.value, { baseUrl: sourceUrl !== null && sourceUrl !== void 0 ? sourceUrl : resourceUrl }); | ||
} | ||
@@ -47,0 +47,0 @@ else { |
@@ -30,3 +30,3 @@ "use strict"; | ||
const utils = __importStar(require("@applitools/utils")); | ||
function extractSvgDependencyUrls(svg, { resourceUrl, pageUrl }) { | ||
function extractSvgDependencyUrls(svg, { resourceUrl, sourceUrl }) { | ||
const urls = new Set(); | ||
@@ -50,3 +50,3 @@ const doc = typeof DOMParser === 'function' | ||
Array.from(doc.querySelectorAll('style')).forEach(element => { | ||
const cssUrls = element.textContent ? (0, extract_css_dependency_urls_1.extractCssDependencyUrls)(element.textContent, { resourceUrl, pageUrl }) : []; | ||
const cssUrls = element.textContent ? (0, extract_css_dependency_urls_1.extractCssDependencyUrls)(element.textContent, { resourceUrl, sourceUrl }) : []; | ||
cssUrls.forEach(url => urls.add(url)); | ||
@@ -53,0 +53,0 @@ }); |
{ | ||
"name": "@applitools/ufg-client", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"homepage": "https://applitools.com", | ||
@@ -5,0 +5,0 @@ "bugs": { |
@@ -19,3 +19,2 @@ import type { Cookie } from '../types'; | ||
export type FetchResourceSettings = { | ||
referer?: string; | ||
proxy?: Proxy; | ||
@@ -27,3 +26,3 @@ autProxy?: Proxy & { | ||
cookies?: Cookie[]; | ||
userAgent?: string; | ||
headers?: Record<string, string | undefined>; | ||
}; | ||
@@ -30,0 +29,0 @@ export type FetchResource = (options: { |
@@ -136,3 +136,2 @@ /// <reference types="node" /> | ||
renderer?: Renderer; | ||
referer?: string; | ||
proxy?: Proxy; | ||
@@ -144,3 +143,3 @@ autProxy?: Proxy & { | ||
cookies?: Cookie[]; | ||
userAgent?: string; | ||
headers?: Record<string, string | undefined>; | ||
} | ||
@@ -147,0 +146,0 @@ export interface RenderTarget { |
@@ -1,4 +0,4 @@ | ||
export declare function extractCssDependencyUrls(css: string, { resourceUrl, pageUrl }: { | ||
export declare function extractCssDependencyUrls(css: string, { resourceUrl, sourceUrl }: { | ||
resourceUrl: string; | ||
pageUrl?: string; | ||
sourceUrl?: string; | ||
}): string[]; |
@@ -1,4 +0,4 @@ | ||
export declare function extractSvgDependencyUrls(svg: string, { resourceUrl, pageUrl }: { | ||
export declare function extractSvgDependencyUrls(svg: string, { resourceUrl, sourceUrl }: { | ||
resourceUrl: string; | ||
pageUrl?: string; | ||
sourceUrl?: string; | ||
}): string[]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116568
1996