域名匹配无效?

时间:2019-07-03 02:13:02

标签: netty

我有以下DomainNameMapping,其中包含以下两个映射。

  

“ *。app.example.com” => A

     

“ *。example.com” => B

当我尝试映射主机“ app.example.com”时,收到输出A。我希望DomainNameMapping会与“ * .example.com”匹配,并返回输出B。

看看Netty源代码,这似乎满足matchs(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())在这种情况下为true。为什么允许这种情况匹配?在我看来,模板应该只匹配在DomainNameMapping中找到的通配符所定义的根域上具有某些子域前缀的主机名。

0 个答案:

没有答案
相关问题