Merge branch 'v1.1-dev' as v1.1.1 v1.1.1
authorJustin Wind <justin.wind+git@gmail.com>
Tue, 10 Aug 2021 21:33:07 +0000 (14:33 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Tue, 10 Aug 2021 21:33:07 +0000 (14:33 -0700)
CHANGELOG.md
package-lock.json
package.json
src/link-helper.js

index e12d6d92f0f188446798550c4ad75e8866192cf4..aaa0b4fa5d4864eab46723c38bc00dfe2986dfc5 100644 (file)
@@ -4,6 +4,12 @@ Releases and notable changes to this project are documented here.
 
 ## [Unreleased]
 
+## [v1.1.1] - 2021-08-09
+
+### Fixed
+
+- Parsing of topic content-types which include encoding.
+
 ## [v1.1.0] - 2021-08-08
 
 ### Added
@@ -21,4 +27,4 @@ Releases and notable changes to this project are documented here.
 
 [Unreleased]: https://git.squeep.com/?p=websub-hub;a=commitdiff;h=HEAD;hp=v1.1.0
 [v1.1.0]: https://git.squeep.com/?p=websub-hub;a=commitdiff;h=v1.1.0;hp=v1.0.0
-[v1.0.0]: https://git.squeep.com/?p=websub-hub;a=commitdiff;h=v1.0.0;hp=v0.0.0
\ No newline at end of file
+[v1.0.0]: https://git.squeep.com/?p=websub-hub;a=commitdiff;h=v1.0.0;hp=v0.0.0
index 401fffd0260dd4ec156a88f2004d0aae25d4d4bc..4a113388f2d35e1091bb99950f8c91299de372dc 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "websub-hub",
-  "version": "1.0.0",
+  "version": "1.1.1",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
       "dev": true
     },
     "@squeep/api-dingus": {
-      "version": "git+https://git.squeep.com/squeep-api-dingus/#12b96f53e7976b74296c1e024432b88749e6c4b0",
-      "from": "git+https://git.squeep.com/squeep-api-dingus/#v1.1-dev",
+      "version": "git+https://git.squeep.com/squeep-api-dingus/#ca35f167826c0732571da5f35e3c25881d138b79",
+      "from": "git+https://git.squeep.com/squeep-api-dingus/#v1.1.0",
       "requires": {
         "mime-db": "^1.49.0",
         "uuid": "^8.3.2"
index d488868e1dacba5b249fff83845947d1ec1ed93e..f1fe201d950858fdb9d7aad31fc45d9e682e67ae 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "websub-hub",
-  "version": "1.1.0",
+  "version": "1.1.1",
   "description": "A WebSub Hub server implementation.",
   "main": "server.js",
   "scripts": {
index 1f3cd0992810f482717f0448781968afb0298723..0517dec6e6d73ba3d9986578e488b87289cbf1b4 100644 (file)
@@ -41,40 +41,46 @@ class LinkHelper {
     // Add Link headers first, as they take priority over link elements in body.
     const linkHeader = getHeader(headers, Enum.Header.Link);
     const links = [];
-    try {
-      links.push(...parseLinkHeader(linkHeader));
-    } catch (e) {
-      if (e instanceof ParseSyntaxError) {
-        this.logger.debug(_scope, 'failed to parse link header, bad syntax', { error: e, linkHeader });
-      } else {
-        this.logger.error(_scope, 'failed to parse link header', { error: e, linkHeader });
+    if (linkHeader) {
+      try {
+        links.push(...parseLinkHeader(linkHeader));
+      } catch (e) {
+        if (e instanceof ParseSyntaxError) {
+          this.logger.debug(_scope, 'failed to parse link header, bad syntax', { error: e, linkHeader });
+        } else {
+          this.logger.error(_scope, 'failed to parse link header', { error: e, linkHeader });
+        }
       }
     }
-
     const contentType = getHeader(headers, Enum.Header.ContentType);
-    let bodyLinks = [];
-    switch (contentType) {
-      case Enum.ContentType.ApplicationAtom:
-      case Enum.ContentType.ApplicationRDF:
-      case Enum.ContentType.ApplicationRSS:
-      case Enum.ContentType.ApplicationXML:
-      case Enum.ContentType.TextXML: {
-        bodyLinks = await this.linksFromFeedBody(url, body);
-        break;
-      }
+    if (contentType) {
+      const [contentTypeBase, _contentTypeEncoding] = contentType.split(/; +/);
+      let bodyLinks = [];
+      switch (contentTypeBase) {
+        case Enum.ContentType.ApplicationAtom:
+        case Enum.ContentType.ApplicationRDF:
+        case Enum.ContentType.ApplicationRSS:
+        case Enum.ContentType.ApplicationXML:
+        case Enum.ContentType.TextXML: {
+          bodyLinks = await this.linksFromFeedBody(url, body);
+          break;
+        }
 
-      case Enum.ContentType.TextHTML:
-        bodyLinks = this.linksFromHTMLBody(body);
-        break;
+        case Enum.ContentType.TextHTML:
+          bodyLinks = this.linksFromHTMLBody(body);
+          break;
 
-      default:
-        this.logger.debug(_scope, 'no parser for content type', { contentType });
+        default:
+          this.logger.debug(_scope, 'no parser for content type', { contentType });
+      }
+      links.push(...bodyLinks);
     }
-    links.push(...bodyLinks);
 
     // Fetch all hub relation targets from headers, resolving relative URIs.
     const hubs = LinkHelper.locateHubTargets(links).map((link) => this.absoluteURI(link, url));
 
+    this.logger.debug(_scope, 'valid hubs for url', { url, hubs });
+
     return hubs.includes(this.selfUrl);
   }