Node.js url 구조

승헌·2021년 6월 10일
0

구조

사용예시

  • pathname 사용
const myURL = new URL('https://example.org/abc/xyz?123');
console.log(myURL.pathname);
// Prints /abc/xyz

myURL.pathname = '/abcdef';
console.log(myURL.href);
// Prints https://example.org/abcdef?123
  • search 사용
const myURL = new URL('https://example.org/abc?123');
console.log(myURL.search);
// Prints ?123

myURL.search = 'abc=xyz';
console.log(myURL.href);
// Prints https://example.org/abc?abc=xyz

더 자세한 것은 Node.js 공식문서 에서 확인하기

profile
https://heony704.github.io/ 이리콤

0개의 댓글