a tool for shared writing and social publishing

fix rkey error

+19 -5
+19 -5
src/utils/uriHelpers.ts
··· 18 18 * or site.standard.publication namespaces. 19 19 */ 20 20 export function publicationUriFilter(did: string, rkey: string): string { 21 - const standard = AtUri.make(did, ids.SiteStandardPublication, rkey).toString(); 21 + const standard = AtUri.make( 22 + did, 23 + ids.SiteStandardPublication, 24 + rkey, 25 + ).toString(); 22 26 const legacy = AtUri.make(did, ids.PubLeafletPublication, rkey).toString(); 23 27 return `uri.eq.${standard},uri.eq.${legacy}`; 24 28 } ··· 27 31 * Returns an OR filter string for Supabase queries to match a publication by name 28 32 * or by either namespace URI. Used when the rkey might be the publication name. 29 33 */ 30 - export function publicationNameOrUriFilter(did: string, nameOrRkey: string): string { 31 - const standard = AtUri.make(did, ids.SiteStandardPublication, nameOrRkey).toString(); 32 - const legacy = AtUri.make(did, ids.PubLeafletPublication, nameOrRkey).toString(); 33 - return `name.eq.${nameOrRkey},uri.eq.${standard},uri.eq.${legacy}`; 34 + export function publicationNameOrUriFilter( 35 + did: string, 36 + nameOrRkey: string, 37 + ): string { 38 + let standard, legacy; 39 + if (/^(?!\.$|\.\.S)[A-Za-z0-9._:~-]{1,512}$/.test(nameOrRkey)) { 40 + standard = AtUri.make( 41 + did, 42 + ids.SiteStandardPublication, 43 + nameOrRkey, 44 + ).toString(); 45 + legacy = AtUri.make(did, ids.PubLeafletPublication, nameOrRkey).toString(); 46 + } 47 + return `name.eq."${nameOrRkey}"",uri.eq."${standard}"",uri.eq."${legacy}"`; 34 48 }