-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
176 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/feeds.toml | ||
/outputs/ | ||
/coverage | ||
/coverage.lcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { site } from "../types/mod.ts"; | ||
|
||
const sites: site[] = [ | ||
{ type: "bluesky", url: new URL("https://bsky.app/profile/{id}/rss") }, | ||
{ type: "note", url: new URL("https://note.com/{id}/rss") }, | ||
{ type: "reddit", url: new URL("https://www.reddit.com/r/{id}/.rss") }, | ||
{ type: "sizu.me", url: new URL("https://sizu.me/{id}/rss") }, | ||
]; | ||
|
||
export function transcodeXmlUrl( | ||
title: string, | ||
type: string | undefined, | ||
id: string | undefined, | ||
): URL { | ||
if (!type) throw new Error(`Parameter not set: "type" of "${title}"`); | ||
if (!id) throw new Error(`Parameter not set: "id" of "${title}"`); | ||
|
||
const url: URL | undefined = sites | ||
.find((site: site) => site.type === type)?.url; | ||
if (!url) throw new Error(`Site not found: "${type}" of "${title}"`); | ||
|
||
return new URL(url.href.replace(encodeURI("{id}"), id)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./toml.ts"; | ||
export * from "./opml.ts"; | ||
export * from "./feed.ts"; | ||
export * from "./sites.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type site = { | ||
type: string; | ||
url: URL; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { assertEquals } from "@std/assert"; | ||
import { transcodeXmlUrl } from "../../src/libs/sites.ts"; | ||
import type { Feed } from "../../src/types/mod.ts"; | ||
|
||
Deno.test("Get XML URL (Site)", () => { | ||
const feed: Feed = { | ||
title: "feed title", | ||
type: "bluesky", | ||
id: "username", | ||
}; | ||
assertEquals( | ||
transcodeXmlUrl(feed.title, feed.type, feed.id), | ||
new URL("https://bsky.app/profile/username/rss"), | ||
); | ||
}); | ||
|
||
Deno.test("Get XML URL (type not set)", () => { | ||
const feed: Feed = { title: "feed title", id: "username" }; | ||
try { | ||
transcodeXmlUrl(feed.title, undefined, feed.id); | ||
} catch (error) { | ||
assertEquals(error.message, `Parameter not set: "type" of "${feed.title}"`); | ||
} | ||
}); | ||
|
||
Deno.test("Get XML URL (id not set)", () => { | ||
const feed: Feed = { title: "feed title", type: "bluesky" }; | ||
try { | ||
transcodeXmlUrl(feed.title, feed.type, undefined); | ||
} catch (error) { | ||
assertEquals(error.message, `Parameter not set: "id" of "${feed.title}"`); | ||
} | ||
}); | ||
|
||
Deno.test("Get XML URL (Site not found)", () => { | ||
const feed: Feed = { title: "feed title", type: "unknown", id: "username" }; | ||
try { | ||
transcodeXmlUrl(feed.title, feed.type, feed.id); | ||
} catch (error) { | ||
assertEquals( | ||
error.message, | ||
`Site not found: "${feed.type}" of "${feed.title}"`, | ||
); | ||
} | ||
}); |