I have an url http://www.example.com/folder/file.html. I want to get domain (example.com
) and path (example.com/folder/
) of the current url.
Using
chrome.tabs.onUpdated.addListener(function(tabid, changeInfo, tab){
chrome.tabs.query({'active' : true, 'currentWindow': true}, function(tabs){
let newUrl = new URL(tabs[0].url);
currentDomain = newUrl.hostname;
});
leads me to getting the host - www.example.com
instead of example.com
.