const link: string = 'https://www.daum.net';
const url: URL = new URL(link);
console.log(url);
// output
/*
URL {
__proto__: URL {
href: 'https://www.daum.net/',
origin: 'https://www.daum.net',
protocol: 'https:',
username: '',
password: '',
host: 'www.daum.net',
hostname: 'www.daum.net',
port: '',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: '',
toJSON: ƒ toJSON(),
toString: ƒ toString(),
constructor: ƒ URL()
}
}
*/
참조:
'코드 > JS' 카테고리의 다른 글
[CJS] module.exports, exports (0) | 2022.12.23 |
---|---|
[NPX] 실행 옵션 (0) | 2022.12.13 |
[JS] Base64 Decode (0) | 2020.05.29 |
[JS] MessageChannel (0) | 2020.05.21 |
[JS] query 읽어 오기 (0) | 2020.05.20 |