Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Indrani-Gostu committed May 16, 2024
1 parent 645e0a3 commit d4ca4ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions packages/@atjson/offset-annotations/src/utils/social-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,15 @@ function normalizeInstagramReelURL(url: IUrl) {
// Threads
// - www.threads.net/:handle/post/:id
function isThreadsURL(url: IUrl) {
return url.host === "threads.net";
return url.host === "www.threads.net";
}

function normalizeThreadsURL(url: IUrl) {
const parts = url.pathname.split("/");
const username = parts[1];
const id = parts[3];
let [username, , id] = without<string>(url.pathname.split("/"), "");

return {
attributes: {
url: `https://threads.net/@${username}/post/${id}`,
url: `https://www.threads.net/${username}/post/${id}`,
},
Class: ThreadsEmbed,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/@atjson/offset-annotations/test/social-urls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ describe("SocialURLs", () => {
describe("identify Threads", () => {
test.each([
[
"https://www.threads.net/@bbc/post/CuZrQ2osUpi",
"https://www.threads.net/@voguemagazine/post/C6v2RQfMvKS",
{
url: "https://www.threads.net/@bbc/post/CuZrQ2osUpi",
url: "https://www.threads.net/@voguemagazine/post/C6v2RQfMvKS",
},
],
])("%s", (url, attributes) => {
Expand Down

0 comments on commit d4ca4ab

Please sign in to comment.