]> Untitled Git - lemmy-ui.git/commitdiff
Fixing RSS for non-local communities. Fixes #53
authorDessalines <tyhou13@gmx.com>
Tue, 13 Oct 2020 21:04:44 +0000 (16:04 -0500)
committerDessalines <tyhou13@gmx.com>
Tue, 13 Oct 2020 21:04:44 +0000 (16:04 -0500)
src/shared/components/community.tsx
src/shared/utils.ts

index 299456bb93c78a5e14ed4008fce406e2740e1a35..f430fe9586496c6ed58a7e1bf27d185fa6b50db6 100644 (file)
@@ -52,6 +52,7 @@ import {
   isBrowser,
   lemmyHttp,
   setAuth,
+  communityRSSUrl,
 } from '../utils';
 import { i18n } from '../i18next';
 
@@ -320,7 +321,10 @@ export class Community extends Component<any, State> {
           <SortSelect sort={this.state.sort} onChange={this.handleSortChange} />
         </span>
         <a
-          href={`/feeds/c/${this.state.communityName}.xml?sort=${this.state.sort}`}
+          href={communityRSSUrl(
+            this.state.communityRes.community.actor_id,
+            this.state.sort
+          )}
           target="_blank"
           title="RSS"
           rel="noopener"
index b3479d3b6e06456a6d35c9a6bb188e5da5e8dbb1..5b14f0db9111f96cfb94e956b9a098cf986a43f5 100644 (file)
@@ -278,6 +278,11 @@ export function validURL(str: string) {
   // }
 }
 
+export function communityRSSUrl(actorId: string, sort: string): string {
+  let url = new URL(actorId);
+  return `${url.origin}/feeds${url.pathname}.xml?sort=${sort}`;
+}
+
 export function validEmail(email: string) {
   let re = /^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))$/;
   return re.test(String(email).toLowerCase());