📅  最后修改于: 2022-03-11 15:01:09.653000             🧑  作者: Mango
url = "http://www.example.com/path/to/somwhere";
urlParts = /^(?:\w+\:\/\/)?([^\/]+)([^\?]*)\??(.*)$/.exec(url);
hostname = urlParts[1]; // www.example.com
path = urlParts[2];