Skip to content

Commit

Permalink
Merge pull request #11 from czue/fix-links
Browse files Browse the repository at this point in the history
Fix links on explitly linked posts
  • Loading branch information
czue authored Dec 5, 2024
2 parents d4d8d97 + df853b4 commit bca3786
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/CommentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Thread = {
replyCount?:number;
};
};
const formatUri = (uri: string): string => {
const getAtUri = (uri: string): string => {
if (!uri.startsWith('at://') && uri.includes('bsky.app/profile/')) {
const match = uri.match(/profile\/([\w.]+)\/post\/([\w]+)/);
if (match) {
Expand Down Expand Up @@ -110,9 +110,11 @@ export const CommentSection = ({ uri: propUri, author, onEmpty, commentFilters }
setVisibleCount((prevCount) => prevCount + 5);
};


const [, , did, _, rkey] = uri.split("/");
const postUrl = `https://bsky.app/profile/${did}/post/${rkey}`;
let postUrl: string = uri;
if (uri.startsWith("at://")) {
const [, , did, _, rkey] = uri.split("/");
postUrl = `https://bsky.app/profile/${did}/post/${rkey}`;
}
const sortedReplies = thread.replies.sort(sortByLikes);

return (
Expand Down Expand Up @@ -243,7 +245,7 @@ const Actions = ({ post }: { post: AppBskyFeedDefs.PostView }) => (
);

const getPostThread = async (uri: string) => {
const atUri = formatUri(uri);
const atUri = getAtUri(uri);
const params = new URLSearchParams({ uri: atUri });

const res = await fetch(
Expand Down

0 comments on commit bca3786

Please sign in to comment.