changeset 28:104a1faebd43

Fix XPath query syntax
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Mon, 21 Jan 2019 08:22:52 +0100
parents 15b828787c8b
children 688d75e554e0
files js/feed-parser.js
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/js/feed-parser.js	Sun Jan 20 17:52:22 2019 +0100
+++ b/js/feed-parser.js	Mon Jan 21 08:22:52 2019 +0100
@@ -341,7 +341,8 @@
         }
 
         let linkElement = feedQueryXPath(this.document, entryElement,
-                './atom03:link[@href][@rel~="alternate"]');
+                './atom03:link[@href][contains(concat(" ", ' +
+                'normalize-space(@rel), " "), " alternate ")]');
         if (linkElement !== null) {
             link = parseURL(linkElement.getAttribute('href'), this.url);
         }
@@ -515,7 +516,8 @@
         }
 
         let linkElement = feedQueryXPath(this.document, entryElement,
-                './atom:link[@href][not(@rel) or @rel~="alternate"]');
+                './atom:link[@href][not(@rel) or contains(concat(" ", ' +
+                'normalize-space(@rel), " "), " alternate ")]');
         if (linkElement !== null) {
             link = parseURL(linkElement.getAttribute('href'), this.url);
         }
@@ -540,7 +542,9 @@
         }
 
         for (let enclosureElement of feedQueryXPathAll(this.document,
-                entryElement, './atom:link[@href][@rel~="enclosure"]')) {
+                entryElement, './atom:link[@href]' +
+                '[contains(concat(" ", normalize-space(@rel), " "), ' +
+                '" enclosure ")]')) {
             try {
                 let entryFile = this.parseAtomEntryFile(enclosureElement);
                 files.push(entryFile);