Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
var url = require('url');
var adr = 'http://domain.ru/images/icon.png?test=132';
var parsedUrl = url.parse(adr, true);
console.log(parsedUrl.host); //returns 'domain.ru'
console.log(parsedUrl.pathname); //returns '/images/icon.png'
console.log(parsedUrl.search); //returns '?test=132'
var queryTest = parsedUrl.query; //returns an object: { test: '132' }
console.log(queryTest.test); //returns 132
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question