코드/JS

[JS] URL 파싱

Yeah-Panda 2020. 12. 22. 22:42
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()
  }
}
*/

참조:

developer.mozilla.org/ko/docs/Web/API/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