comparison js/feed-parser.js @ 28:104a1faebd43

Fix XPath query syntax
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Mon, 21 Jan 2019 08:22:52 +0100
parents da483ce3832d
children 76e23b361e92
comparison
equal deleted inserted replaced
27:15b828787c8b 28:104a1faebd43
339 if (titleElement !== null) { 339 if (titleElement !== null) {
340 title = titleElement.textContent.trim(); 340 title = titleElement.textContent.trim();
341 } 341 }
342 342
343 let linkElement = feedQueryXPath(this.document, entryElement, 343 let linkElement = feedQueryXPath(this.document, entryElement,
344 './atom03:link[@href][@rel~="alternate"]'); 344 './atom03:link[@href][contains(concat(" ", ' +
345 'normalize-space(@rel), " "), " alternate ")]');
345 if (linkElement !== null) { 346 if (linkElement !== null) {
346 link = parseURL(linkElement.getAttribute('href'), this.url); 347 link = parseURL(linkElement.getAttribute('href'), this.url);
347 } 348 }
348 349
349 let modifiedElement = feedQueryXPath(this.document, entryElement, 350 let modifiedElement = feedQueryXPath(this.document, entryElement,
513 if (titleElement !== null) { 514 if (titleElement !== null) {
514 title = this.parseAtomTextConstruct(titleElement); 515 title = this.parseAtomTextConstruct(titleElement);
515 } 516 }
516 517
517 let linkElement = feedQueryXPath(this.document, entryElement, 518 let linkElement = feedQueryXPath(this.document, entryElement,
518 './atom:link[@href][not(@rel) or @rel~="alternate"]'); 519 './atom:link[@href][not(@rel) or contains(concat(" ", ' +
520 'normalize-space(@rel), " "), " alternate ")]');
519 if (linkElement !== null) { 521 if (linkElement !== null) {
520 link = parseURL(linkElement.getAttribute('href'), this.url); 522 link = parseURL(linkElement.getAttribute('href'), this.url);
521 } 523 }
522 524
523 let updatedElement = feedQueryXPath(this.document, entryElement, 525 let updatedElement = feedQueryXPath(this.document, entryElement,
538 content = this.parseAtomTextConstruct(summaryElement, false); 540 content = this.parseAtomTextConstruct(summaryElement, false);
539 } 541 }
540 } 542 }
541 543
542 for (let enclosureElement of feedQueryXPathAll(this.document, 544 for (let enclosureElement of feedQueryXPathAll(this.document,
543 entryElement, './atom:link[@href][@rel~="enclosure"]')) { 545 entryElement, './atom:link[@href]' +
546 '[contains(concat(" ", normalize-space(@rel), " "), ' +
547 '" enclosure ")]')) {
544 try { 548 try {
545 let entryFile = this.parseAtomEntryFile(enclosureElement); 549 let entryFile = this.parseAtomEntryFile(enclosureElement);
546 files.push(entryFile); 550 files.push(entryFile);
547 } catch (e) { 551 } catch (e) {
548 if (!(e instanceof TypeError)) { 552 if (!(e instanceof TypeError)) {