fix wrong ebook name if page has no title

This commit is contained in:
alexadam 2016-09-21 17:17:14 +03:00
parent f9e615501d
commit 79609be75d

View file

@ -241,7 +241,10 @@ function getPageUrl(url) {
return url.toLowerCase().replace(/\s+/g,'_').replace(/[^a-z0-9_]/g,'') + Math.floor(Math.random() * 10000) + '.xhtml';
}
function getPageTitle(title) { //TODO
function getPageTitle(title) {
if (title.trim().length === 0) {
return 'ebook';
}
return title;
}
@ -309,9 +312,10 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
});
$.when.apply($, imgsPromises).done(function() {
var tmpTitle = getPageTitle(document.title);
result = {
url: getPageUrl(document.title),
title: getPageTitle(document.title),
url: getPageUrl(tmpTitle),
title: tmpTitle,
baseUrl: getCurrentUrl(),
images: extractedImages,
content: tmpContent