A calm place to write long-form, and publish it to the open social web. skypress.blog/
0

Configure Feed

Select the types of activity you want to include in your feed.

Harden cc-line index + cover multibyte handle offsets

+19 -1
+17
src/lib/publish/post-text.test.ts
··· 78 78 ); 79 79 expect( slice ).toBe( '@alice.bsky.social' ); 80 80 } ); 81 + 82 + it( 'computes correct byte offsets for a multibyte handle', () => { 83 + const handle = 'señor.bsky.social'; 84 + const { text, facets } = assemblePostText( { 85 + title: 'Hi', 86 + articleUrl: URL, 87 + mentions: [ { did: 'did:plc:s', handle, displayText: `@${ handle }` } ], 88 + } ); 89 + const mention = facets.find( 90 + ( f ) => f.features[ 0 ].$type === 'app.bsky.richtext.facet#mention' 91 + )!; 92 + const buf = new TextEncoder().encode( text ); 93 + const slice = new TextDecoder().decode( 94 + buf.slice( mention.index.byteStart, mention.index.byteEnd ) 95 + ); 96 + expect( slice ).toBe( `@${ handle }` ); 97 + } ); 81 98 } );
+2 -1
src/lib/publish/post-text.ts
··· 60 60 61 61 // Mention facets (each @handle inside the cc line). 62 62 if ( ccLine ) { 63 - const ccIndex = segments.indexOf( ccLine ); 63 + // The cc line, when present, is always the second-to-last segment (before the URL). 64 + const ccIndex = segments.length - 2; 64 65 let local = utf8ByteLength( 'cc ' ); 65 66 mentions.forEach( ( mention, i ) => { 66 67 if ( i > 0 ) {