我想to use URI.js解析URL以获取不带“ www。”的主机名。
const hostname = URI('http//www.example.com').hostname()
// -> Produces: 'www.example.com'
// Instead, I want: 'example.com'
我在做什么错?
应该是
const hostname = URI('http//www.example.com').domain()
关于https://medialize.github.io/URI.js/docs.html#accessors-domain的更多详细信息