다시 직렬화 할때는 url.format()메서드를 사용
var url = require('url');
var obj = url.parse('https://www.google.co.kr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#newwindow=1&q=sharpscar\'s%20crab%20pot');
console.log('url to Object : ', obj);
console.log("=====================");
console.log('Object to URL :', url.format(obj));
결과
url to Object : { protocol: 'https:',
slashes: true,
auth: null,
host: 'www.google.co.kr',
port: null,
hostname: 'www.google.co.kr',
hash: '#newwindow=1&q=sharpscar%27s%20crab%20pot',
search: '?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8',
query: 'sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8',
pathname: '/webhp',
path: '/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8',
href: 'https://www.google.co.kr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#newwindow=1&q=sharpscar%27s%20crab%20pot' }
=====================
Object to URL : https://www.google.co.kr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#newwindow=1&q=sharpscar%27s%20crab%20pot
댓글 없음:
댓글 쓰기