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 => {
name: let attrValue = attr.value;
"[" +
cssesc(attr.name, { isIdentifier: true }) + if (attr.name === "href" && attr.value.includes("://")) {
'="' + try {
cssesc(attr.value) + const url = new URL(attr.value);
'"]', const siteOrigin = `${url.protocol}//${url.host}`;
penalty: 0.5, attrValue = attr.value.replace(siteOrigin, "");
}) } catch (e) {
// Keep original if URL parsing fails
}
}
return {
name:
"[" +
cssesc(attr.name, { isIdentifier: true }) +
'="' +
cssesc(attrValue) +
'"]',
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);