【发布时间】:2015-11-03 16:51:01
【问题描述】:
有没有一种懒惰的方法来获取“顶级”主机的变量而不诉诸 if()?
- example.com:返回 example.com,
- cabbages.example.com:返回 example.com,
- carrots.example.com:返回 example.com,
- otherexample.com:返回 otherexample.com,
- cabbages.otherexample.com:返回 otherexample.com,
- carots.otherexample.com:返回 otherexample.com,
【问题讨论】:
-
cabbages.example.co.uk怎么样?要做到这一点,需要了解每个顶级域的命名约定。
标签: javascript