Skip to content

Commit

Permalink
chore: remove telegram embed from social identification
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-evans committed May 30, 2024
1 parent 4c34c05 commit 91fbe8c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
22 changes: 0 additions & 22 deletions packages/@atjson/offset-annotations/src/utils/social-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
GiphyEmbed,
InstagramEmbed,
PinterestEmbed,
TelegramEmbed,
TikTokEmbed,
TwitterEmbed,
} from "../annotations";
Expand Down Expand Up @@ -361,23 +360,6 @@ function normalizeTikTokUrl(url: IUrl) {
};
}

// Telegram URLs
// Needs to covert post URL (https://t.me/:channelSlug/:postId) to post slug (:channelSlug/:postId)
// Docs here https://core.telegram.org/widgets/post

function isTelegramUrl(url: IUrl) {
return url.host === "t.me";
}

function normalizeTelegramUrl(url: IUrl) {
let [cahnnelSlug, postId] = without<string>(url.pathname.split("/"), "");
return {
Class: TelegramEmbed,
attributes: {
url: `${cahnnelSlug}/${postId}`,
},
};
}
function isRedditURL(url: IUrl) {
return (
(url.host === "www.redditmedia.com" && url.pathname.startsWith("/r/")) ||
Expand Down Expand Up @@ -462,9 +444,5 @@ export function identify(url: IUrl) {
return normalizeTikTokUrl(url);
}

if (isTelegramUrl(url)) {
return normalizeTelegramUrl(url);
}

return null;
}
30 changes: 1 addition & 29 deletions packages/@atjson/offset-annotations/test/social-urls.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
IframeEmbed,
TelegramEmbed,
SocialURLs,
InstagramEmbed,
TwitterEmbed,
} from "../src";
import { IframeEmbed, SocialURLs, InstagramEmbed, TwitterEmbed } from "../src";

describe("SocialURLs", () => {
describe("identify Spotify", () => {
Expand Down Expand Up @@ -147,28 +141,6 @@ describe("SocialURLs", () => {
});
});

describe("identify Telegram", () => {
test.each([
[
"https://t.me/voguerussia/8714/",
{
url: "voguerussia/8714",
},
],
[
"http://t.me/tatlerbutler/3416",
{
url: "tatlerbutler/3416",
},
],
])("%s", (url, attributes) => {
expect(SocialURLs.identify(new URL(url))).toMatchObject({
Class: TelegramEmbed,
attributes,
});
});
});

describe("identify Reddit", () => {
test.each([
[
Expand Down

0 comments on commit 91fbe8c

Please sign in to comment.