@pipedream/bluesky 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "bluesky-create-post",
|
|
6
6
|
name: "Create Post",
|
|
7
7
|
description: "Creates a new post on Bluesky. [See the documentation](https://docs.bsky.app/docs/api/com-atproto-repo-create-record).",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
app,
|
|
@@ -15,6 +15,40 @@ export default {
|
|
|
15
15
|
description: "The text content of the post.",
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
+
methods: {
|
|
19
|
+
parseUrls(text) {
|
|
20
|
+
const spans = [];
|
|
21
|
+
const urlRegex = /(?:[$|\W])(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*[-a-zA-Z0-9@%_+~#//=])?)/g;
|
|
22
|
+
|
|
23
|
+
let match;
|
|
24
|
+
while ((match = urlRegex.exec(text)) !== null) {
|
|
25
|
+
spans.push({
|
|
26
|
+
start: match.index + 1,
|
|
27
|
+
end: urlRegex.lastIndex,
|
|
28
|
+
url: match[1],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return spans;
|
|
32
|
+
},
|
|
33
|
+
parseFacets(text) {
|
|
34
|
+
const facets = [];
|
|
35
|
+
for (const link of this.parseUrls(text)) {
|
|
36
|
+
facets.push({
|
|
37
|
+
index: {
|
|
38
|
+
byteStart: link["start"],
|
|
39
|
+
byteEnd: link["end"],
|
|
40
|
+
},
|
|
41
|
+
features: [
|
|
42
|
+
{
|
|
43
|
+
["$type"]: "app.bsky.richtext.facet#link",
|
|
44
|
+
uri: link["url"],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return facets;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
18
52
|
async run({ $ }) {
|
|
19
53
|
const {
|
|
20
54
|
app,
|
|
@@ -28,6 +62,7 @@ export default {
|
|
|
28
62
|
record: {
|
|
29
63
|
["$type"]: constants.RESOURCE_TYPE.POST,
|
|
30
64
|
text,
|
|
65
|
+
facets: this.parseFacets(text),
|
|
31
66
|
createdAt: new Date().toISOString(),
|
|
32
67
|
},
|
|
33
68
|
},
|