include filename in screenshot for html file

This commit is contained in:
Suresh 2020-05-27 22:01:20 +05:30
parent 83accd35d0
commit 44c7efb0b8

View file

@ -194,11 +194,23 @@ function _getScreenshotFileName(
}
const _getWebsiteName = address => {
let domain = new URL(address).hostname;
domain = domain.replace('www.', '');
const dotIndex = domain.indexOf('.');
if (dotIndex > -1) {
domain = domain.substr(0, domain.indexOf('.'));
let domain='';
if(address.startsWith("file://")){
let fileNameStartingIndex=address.lastIndexOf('/')+1;
let htmIndex=address.indexOf('.htm');
if(htmIndex==-1){
htmIndex=address.length;
}
domain=address.substring(fileNameStartingIndex,htmIndex);
console.log(domain)
}else{
domain = new URL(address).hostname;
domain = domain.replace('www.', '');
const dotIndex = domain.indexOf('.');
if (dotIndex > -1) {
domain = domain.substr(0, domain.indexOf('.'));
}
}
return domain.charAt(0).toUpperCase() + domain.slice(1);
};
};