• {string}

    获取只读的序列化的 URL 的 origin。

    1. const myURL = new URL('https://example.org/foo/bar?baz');
    2. console.log(myURL.origin);
    3. // 打印 https://example.org
    1. const idnURL = new URL('https://測試');
    2. console.log(idnURL.origin);
    3. // 打印 https://xn--g6w251d
    4. console.log(idnURL.hostname);
    5. // 打印 xn--g6w251d