Merge pull request #682 from getmaxun/hrefsel-fix

fix: href selector revamp
This commit is contained in:
Karishma Shukla
2025-07-09 19:15:31 +05:30
committed by GitHub

View File

@@ -1553,15 +1553,29 @@ class ClientSelectorGenerator {
); );
return attrs.map( return attrs.map(
(attr): Node => ({ (attr): Node => {
let attrValue = attr.value;
if (attr.name === "href" && attr.value.includes("://")) {
try {
const url = new URL(attr.value);
const siteOrigin = `${url.protocol}//${url.host}`;
attrValue = attr.value.replace(siteOrigin, "");
} catch (e) {
// Keep original if URL parsing fails
}
}
return {
name: name:
"[" + "[" +
cssesc(attr.name, { isIdentifier: true }) + cssesc(attr.name, { isIdentifier: true }) +
'="' + '="' +
cssesc(attr.value) + cssesc(attrValue) +
'"]', '"]',
penalty: 0.5, penalty: 0.5,
}) };
}
); );
} }
@@ -3526,8 +3540,8 @@ class ClientSelectorGenerator {
const elementInfo = this.getElementInformation( const elementInfo = this.getElementInformation(
iframeDocument, iframeDocument,
coordinates, coordinates,
this.listSelector, '',
this.getList false
); );
const selectorBasedOnCustomAction = this.getSelectors(iframeDocument, coordinates); const selectorBasedOnCustomAction = this.getSelectors(iframeDocument, coordinates);