netty - DomainNameMapping 匹配无效?
问题描述
我有以下 DomainNameMapping ,其中包含以下两个映射。
"*.app.example.com" => A
"*.example.com" => B
当我尝试映射“app.example.com”的主机时,我收到输出 A。我希望 DomainNameMapping 会改为匹配“*.example.com”并返回输出 B。
查看 Netty 源代码,这似乎满足了 matches(String, String) 方法的第一个条件。
static boolean matches(String template, String hostName) {
if (template.startsWith("*.")) {
return template.regionMatches(2, hostName, 0, hostName.length())
|| commonSuffixOfLength(hostName, template, template.length() - 1);
}
return template.equals(hostName);
}
即,template.regionMatches(2, hostName, 0, hostName.length())
在这种情况下为真。为什么允许这种情况匹配?在我看来,模板应该只匹配在 DomainNameMapping 中找到的通配符定义的根域上具有一些子域前缀的主机名。
解决方案
推荐阅读
- python - 如何在python中部分下载CSV
- mysql - 如何编写一个 MySQL 函数来根据名称提取 JSONAttribute 的值?
- c# - 从列表中获取不同的对象
- c# - 如何在 C# 中沿水平滑块统一小部件定义停止点?
- c# - 如何使用机器人将超链接嵌入到 Telegram 中的字符串中?
- variables - 为什么我的 Scratch Cloud 变量没有更新?
- python - How do I install a package I find on rosindex.github.io?
- excel - 来自模块的工作表 SelectionChange 事件
- java - Glide 仅显示第一张图片
- karate - Use conditional logic in Scenario Outline with lists