Skip to content

Commit

Permalink
#6 URLから投稿IDを抜き出す
Browse files Browse the repository at this point in the history
  • Loading branch information
amay077 committed Jan 4, 2025
1 parent 5a0f7c2 commit 09d227a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib/MainContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@ const post = async () => {
try {
posting = true;
const getPostId = (url: string) => {
if ((url?.length ?? 0) == 0) {
return '';
}
const urlObj = new URL(url);
const pathParts = urlObj.pathname.split('/');
return pathParts[pathParts.length - 1];
};
const res = await postToSns(text, imageDataURLs, { reply_to_ids: {
mastodon: replyToIdForMastodon,
twitter: replyToIdForTwitter,
bluesky: replyToIdForBluesky,
mastodon: getPostId(replyToIdForMastodon),
twitter: getPostId(replyToIdForTwitter),
bluesky: getPostId(replyToIdForBluesky),
} });
if (res.errors.length == 0) {
Expand Down

0 comments on commit 09d227a

Please sign in to comment.