Skip to content

Unable to find match using selectors with a colon in the attribute value #50

@chlao

Description

@chlao

I'm attempting to replace the a Google Fonts stylesheet URL with the contents of the stylesheet. I was using HTMLRewriter about a week ago and it was working fine, but I noticed today after I published to my worker, that it stopped working as expected even though it I had not made any changes that would have made a difference.

So, I started testing out different selectors. This seems to work fine:

rewriter.on(`link[href*="fonts.googleapis.com/css"]`, ...)

But, when a colon was added to the font, it wouldn't work, and the handler would not be called:

rewriter.on(`link[href*=":fonts.googleapis.com/css"]`, ...)

I was having issues with these two cases as well. This works fine:

rewriter.on(`[href*="fonts.googleapis.com/css?family"]`, ...)

But, this does not:

rewriter.on(`[href*=fonts.googleapis.com/css?family=Lato"]`, ...)

It feels like the last two cases could be an issue with the equals sign.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions