File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export default {
55 key : "bluesky-create-post" ,
66 name : "Create Post" ,
77 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.1 " ,
8+ version : "0.0.2 " ,
99 type : "action" ,
1010 props : {
1111 app,
@@ -15,6 +15,40 @@ export default {
1515 description : "The text content of the post." ,
1616 } ,
1717 } ,
18+ methods : {
19+ parseUrls ( text ) {
20+ const spans = [ ] ;
21+ const urlRegex = / (?: [ $ | \W ] ) ( h t t p s ? : \/ \/ ( w w w \. ) ? [ - a - z A - Z 0 - 9 @ : % . _ + ~ # = ] { 1 , 256 } \. [ a - z A - Z 0 - 9 ( ) ] { 1 , 6 } \b ( [ - a - z A - Z 0 - 9 ( ) @ : % _ + . ~ # ? & / / = ] * [ - a - z A - Z 0 - 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+ } ,
1852 async run ( { $ } ) {
1953 const {
2054 app,
@@ -28,6 +62,7 @@ export default {
2862 record : {
2963 [ "$type" ] : constants . RESOURCE_TYPE . POST ,
3064 text,
65+ facets : this . parseFacets ( text ) ,
3166 createdAt : new Date ( ) . toISOString ( ) ,
3267 } ,
3368 } ,
Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/bluesky" ,
3- "version" : " 0.1.0 " ,
3+ "version" : " 0.1.1 " ,
44 "description" : " Pipedream Bluesky Components" ,
55 "main" : " bluesky.app.mjs" ,
66 "keywords" : [
You can’t perform that action at this time.
0 commit comments