我试图将 url 字符串拆分为子字符串,以便我只使用网站的域名,例如https://nodejs.org/api/console.html
应为 nodejs.org
,http://postgresql.com
应为 postgresql.com
我已尝试使用以下代码行解决此问题:
filePath[i].split('/').pop()
但这仅适用于不包含域后文件的网址,例如http://postgresql.com
我怎样才能达到这个结果?
答案 0 :(得分:2)