angularjs, şu yol buldum:Javascript url ayrıştırmak çalışıyorum javascript url Ayrıştırma veya
var getLocation = function(href) {
var l = document.createElement("a");
l.href = href;
return l;
};
var l = getLocation("http://example.com:3000/path");
var host = l.host; // example.com
var port = l.port; // 3000
Fakat bu yerlerin eğer bir sorunla karşı karşıya:
http://TLVS0015:3000/cti/YTest // the parse found the port, but its not found the host
http://ctmwe:80/ReportServer/ReportService2010.asmx // the parse found the host, but don't found the port
mi var ayrıştırmayı yapmak için başka bir yol var mı?
'yapmayı deneyin l.hostname' – aug
http://james.padolsey.com/javascript/parsing- urls-with-the-dom/ – smarber
Eğer zaten URL'niz varsa, bölme() ve bileşenleri almak daha iyi olmaz mı? (Daha sonra bir nesne yaratmak istiyorum) Eğer bu şekilde yapmanın bir yararı varsa o zaman dizeleri kullanmak yerine? – atmd