Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/cli/src/social-follow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ describe('social follow target parsing', () => {
expect(() => parseSocialFollowTarget('https://example.com/alice')).toThrow('only supports bsky.app URLs');
});

it('rejects malformed Bluesky profile URLs with a useful error', () => {
expect(() => parseSocialFollowTarget('https://bsky.app/profile/%E0%A4%A')).toThrow(
'Could not parse Bluesky profile URL',
);
});

it('normalizes follow actions', () => {
expect(normalizeFollowAction(undefined)).toBe('follow');
expect(normalizeFollowAction('follow')).toBe('follow');
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/social-follow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ export function parseSocialFollowTarget(input: string, explicitPlatform?: string
throw new Error(`social follow only supports bsky.app URLs today; got ${host}`);
}

const segments = url.pathname.split('/').filter(Boolean).map(decodeURIComponent);
let segments: string[];
try {
segments = url.pathname.split('/').filter(Boolean).map(decodeURIComponent);
} catch {
throw new Error(`Could not parse Bluesky profile URL ${input}`);
}
const profileIndex = segments.indexOf('profile');
const actor = profileIndex >= 0 ? segments[profileIndex + 1] : undefined;
if (!actor) throw new Error(`Could not find a Bluesky profile handle or DID in ${input}`);
Expand Down
Loading