Skip to content

Commit 1be9efe

Browse files
fix(cli): handle malformed Bluesky profile URLs (#728)
Co-authored-by: rissrice2105-agent <rissrice2105-agent@users.noreply.github.com>
1 parent 39ddf2e commit 1be9efe

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

packages/cli/src/social-follow.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ describe('social follow target parsing', () => {
3939
expect(() => parseSocialFollowTarget('https://example.com/alice')).toThrow('only supports bsky.app URLs');
4040
});
4141

42+
it('rejects malformed Bluesky profile URLs with a useful error', () => {
43+
expect(() => parseSocialFollowTarget('https://bsky.app/profile/%E0%A4%A')).toThrow(
44+
'Could not parse Bluesky profile URL',
45+
);
46+
});
47+
4248
it('normalizes follow actions', () => {
4349
expect(normalizeFollowAction(undefined)).toBe('follow');
4450
expect(normalizeFollowAction('follow')).toBe('follow');

packages/cli/src/social-follow.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ export function parseSocialFollowTarget(input: string, explicitPlatform?: string
9595
throw new Error(`social follow only supports bsky.app URLs today; got ${host}`);
9696
}
9797

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

0 commit comments

Comments
 (0)