如何将非ASCII字符在DECLARATIVENETREQUEST API的REGEX过滤器中用于Google Chrome扩展名?
I am creating a Chrome extension but just found out that it's not possible to use non-ascii characters in the
我目前在指定以下条件指定的规则集中使用块操作,这可以正常工作:
"condition": {"regexFilter": "^(.*):\/\/(.*).(ru|su|tatar)\/(.*)", "resourceTypes": ["main_frame"] }
但是,我仍然想添加tlds ph 和滤网。我也尝试在正则表达式中使用Unicode编码的表示形式,但也没有用。那么,如何在google chrome扩展名的DECLARATIVENETREQUEST API的REGEX过滤器中使用非ASCII字符?还是有其他方法可以实现这一目标?
side Note:我觉得这个问题更属于“ Web Applications”堆栈交换,但是考虑到Google-Chrome-Extensions的标签具有 27.000+问题在stackoverflow上和在WebApps stack Exchange上,我认为将其发布在此处更有效。
I am creating a Chrome extension but just found out that it's not possible to use non-ascii characters in the regex filter of the declarativeNetRequest API. Which I need because I want to use it to match and block all requests to domains with TLD рф and дети. Is there any solution for this?
I currently use a block action in a ruleset specified with the following condition and this works fine:
"condition": {"regexFilter": "^(.*):\/\/(.*).(ru|su|tatar)\/(.*)", "resourceTypes": ["main_frame"] }
However, I still want to add TLDs рф and дети. I tried using a Unicode-encoded representation of that in the regex too but it also didn't work. So, how to use non-ascii characters in the regex filter of the declarativeNetRequest API for a Google Chrome extension? Or is there an alternative approach to achieve this?
Side-note: I feel like this question belongs more the "Web Applications" Stack Exchange, however considering the tag google-chrome-extensions has 27.000+ questions on StackOverflow and less than 100 questions on WebApps Stack Exchange I think it's more effective to post it here .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,为了完整。正如用户woxxom在问题的评论中提到的那样。 PunyCode是国际化领域的解决方案。
因此,为了匹配tlds em 和детиi,我使用了此正则:
我将其转换为punycode, https://www.punycoder.com/ 。
So for the sake of completeness. As user wOxxOm mentioned in the comments of the question. Punycode is the solution in cases of internationalized domains.
So in order to match the TLDs рф and детиI I used this regex instead:
I converted it to Punycode using, https://www.punycoder.com/.