openstyles/stylus

[Bug] URLs do not match when a custom port is used

unikitty37 opened this issue · 2 comments

Bug Report

Bug Description

When the URL uses a custom port, such as http://192.168.1.10:3000, and Stylus is configured to match "URLs on the domain: 192.168.1.10:3000", the styles are not applied.

They can be applied by removing the ":3000" and just using "URLs on the domain: 192.168.1.10", but this then causes them to be applied to pages served from other ports on the same server.

The same problem occurs with "URL", "URLs starting with", and "URLs matching the regexp" — the port is not available for matching.

Screenshots

CSS Code

System Information

  • OS: macOS 14.4.1 (23E224)
  • Browser: Vivaldi 6.7.3329.31 (Stable channel) (arm64)
  • Stylus Version: 1.5.46

Additional Context

Having access to the port number would be useful for machines running multiple services from Docker; the alternative is to set up a reverse proxy and add DNS entries for all the services I want to tweak the CSS on…

Works for me using URL, URLs starting with, URLs matching the regexp.

@-moz-document url("http://localhost:8080/test.html") {
  body { color: red }
}
@-moz-document url-prefix("http://localhost:8080/") {
  body { color: red }
}
@-moz-document regexp("http://localhost:8080/.*") {
  body { color: red }
}

Note that when you change the matching mode you also need to provide a valid URL/pattern for that mode, it can't be the same as domain value. As for domain, the initial documentation says "host subcomponent (as defined in URI)" and doesn't include the port. There's no bug in the matching code, it's also how other userstyle extensions work, so I'll just fix the UI by moving the port from domain to url-prefix.