A url resource that is a dot (%2E)

It’s actually not really clearly stated in the standard (RFC 3986) whether a percent-encoded version of . or .. is supposed to have the same this-folder/up-a-folder meaning as the unescaped version. Section 3.3 only talks about “The path segments . and ..”, without clarifying whether they match . and .. before or after pct-encoding. Personally … Read more

How to find Port number of IP address?

Unfortunately the standard DNS A-record (domain name to IP address) used by web-browsers to locate web-servers does not include a port number. Web-browsers use the URL protocol prefix (http://) to determine the port number (http = 80, https = 443, ftp = 21, etc.) unless the port number is specifically typed in the URL (for … Read more

How to fetch URL of current Tab in my chrome extension using javascript

Note you must have the tabs permission set in your manifest file “permissions”: [ “tabs” ], http://developer.chrome.com/extensions/tabs.html or the activeTab permission if initiated by a click on the extension button[Xan] https://developer.chrome.com/extensions/activeTab Code: chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ console.log(tabs[0].url); });

Get relative URL from absolute URL

A nice way to do this is to use the browser’s native link-parsing capabilities, using an a element: function getUrlParts(url) { var a = document.createElement(‘a’); a.href = url; return { href: a.href, host: a.host, hostname: a.hostname, port: a.port, pathname: a.pathname, protocol: a.protocol, hash: a.hash, search: a.search }; } You can then access the pathname with … Read more