From f7e2c58c728a1d2c770c0da5c0b38d1462762f99 Mon Sep 17 00:00:00 2001 From: kawamataryo Date: Fri, 18 Oct 2024 09:10:11 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20support=20handle=20name=20in=20dash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/bskyHelpers.ts | 4 +++- src/lib/domHelpers.ts | 3 ++- src/lib/searchBskyUsers.ts | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/bskyHelpers.ts b/src/lib/bskyHelpers.ts index 6a16267..085d395 100644 --- a/src/lib/bskyHelpers.ts +++ b/src/lib/bskyHelpers.ts @@ -4,6 +4,7 @@ import { BSKY_USER_MATCH_TYPE } from "./constants"; type Names = { accountName: string; accountNameRemoveUnderscore: string; + accountNameReplaceUnderscore: string; displayName: string; }; @@ -36,7 +37,8 @@ export const isSimilarUser = ( if ( lowerCaseNames.accountName === bskyHandle || - lowerCaseNames.accountNameRemoveUnderscore === bskyHandle + lowerCaseNames.accountNameRemoveUnderscore === bskyHandle || + lowerCaseNames.accountNameReplaceUnderscore === bskyHandle ) { return { isSimilar: true, diff --git a/src/lib/domHelpers.ts b/src/lib/domHelpers.ts index f39fbc9..e9dcb0c 100644 --- a/src/lib/domHelpers.ts +++ b/src/lib/domHelpers.ts @@ -23,6 +23,7 @@ export const getAccountNameAndDisplayName = (userCell: Element) => { const [avatarEl, displayNameEl] = userCell.querySelectorAll("a"); const twAccountName = avatarEl?.getAttribute("href")?.replace("/", ""); const twAccountNameRemoveUnderscore = twAccountName.replaceAll("_", ""); // bsky does not allow underscores in handle, so remove them. + const twAccountNameReplaceUnderscore = twAccountName.replaceAll("_", "-"); const twDisplayName = displayNameEl?.textContent; - return { twAccountName, twDisplayName, twAccountNameRemoveUnderscore }; + return { twAccountName, twDisplayName, twAccountNameRemoveUnderscore, twAccountNameReplaceUnderscore }; }; diff --git a/src/lib/searchBskyUsers.ts b/src/lib/searchBskyUsers.ts index 9d8e665..e3c542a 100644 --- a/src/lib/searchBskyUsers.ts +++ b/src/lib/searchBskyUsers.ts @@ -12,6 +12,7 @@ export const searchBskyUser = async ({ }) => { const searchTerms = [ userData.twAccountNameRemoveUnderscore, + userData.twAccountNameReplaceUnderscore, userData.twDisplayName, ]; @@ -32,6 +33,7 @@ export const searchBskyUser = async ({ { accountName: userData.twAccountName, accountNameRemoveUnderscore: userData.twAccountNameRemoveUnderscore, + accountNameReplaceUnderscore: userData.twAccountNameReplaceUnderscore, displayName: userData.twDisplayName, }, searchResult,