tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
292
fork
atom
a tool for shared writing and social publishing
292
fork
atom
overview
issues
27
pulls
pipelines
fix rkey error
awarm.space
2 months ago
fc9c9270
69de7db6
+19
-5
1 changed file
expand all
collapse all
unified
split
src
utils
uriHelpers.ts
+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
21
-
const standard = AtUri.make(did, ids.SiteStandardPublication, rkey).toString();
21
21
+
const standard = AtUri.make(
22
22
+
did,
23
23
+
ids.SiteStandardPublication,
24
24
+
rkey,
25
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
30
-
export function publicationNameOrUriFilter(did: string, nameOrRkey: string): string {
31
31
-
const standard = AtUri.make(did, ids.SiteStandardPublication, nameOrRkey).toString();
32
32
-
const legacy = AtUri.make(did, ids.PubLeafletPublication, nameOrRkey).toString();
33
33
-
return `name.eq.${nameOrRkey},uri.eq.${standard},uri.eq.${legacy}`;
34
34
+
export function publicationNameOrUriFilter(
35
35
+
did: string,
36
36
+
nameOrRkey: string,
37
37
+
): string {
38
38
+
let standard, legacy;
39
39
+
if (/^(?!\.$|\.\.S)[A-Za-z0-9._:~-]{1,512}$/.test(nameOrRkey)) {
40
40
+
standard = AtUri.make(
41
41
+
did,
42
42
+
ids.SiteStandardPublication,
43
43
+
nameOrRkey,
44
44
+
).toString();
45
45
+
legacy = AtUri.make(did, ids.PubLeafletPublication, nameOrRkey).toString();
46
46
+
}
47
47
+
return `name.eq."${nameOrRkey}"",uri.eq."${standard}"",uri.eq."${legacy}"`;
34
48
}