This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 93
93
},
94
94
"dependencies" : {
95
95
"async" : " ^2.6.0" ,
96
+ "binary-querystring" : " ^0.1.1" ,
96
97
"bl" : " ^1.2.1" ,
97
98
"boom" : " ^7.1.1" ,
98
99
"bs58" : " ^4.0.1" ,
Original file line number Diff line number Diff line change 2
2
3
3
const PassThrough = require ( 'stream' ) . PassThrough
4
4
const bs58 = require ( 'bs58' )
5
+ const binaryQueryString = require ( 'binary-querystring' )
5
6
6
7
exports = module . exports
7
8
@@ -58,7 +59,9 @@ exports.publish = {
58
59
handler : ( request , reply ) => {
59
60
const arg = request . query . arg
60
61
const topic = arg [ 0 ]
61
- const buf = arg [ 1 ]
62
+
63
+ const rawArgs = binaryQueryString ( request . url . search )
64
+ const buf = rawArgs . arg [ 1 ]
62
65
63
66
const ipfs = request . server . app . ipfs
64
67
@@ -70,7 +73,7 @@ exports.publish = {
70
73
return reply ( new Error ( 'Missing buf' ) )
71
74
}
72
75
73
- ipfs . pubsub . publish ( topic , Buffer . from ( String ( buf ) ) , ( err ) => {
76
+ ipfs . pubsub . publish ( topic , buf , ( err ) => {
74
77
if ( err ) {
75
78
return reply ( new Error ( `Failed to publish to topic ${ topic } : ${ err } ` ) )
76
79
}
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ describe('pubsub', function () {
83
83
] , done )
84
84
} )
85
85
} )
86
-
86
+
87
87
describe ( 'ascii data' , ( ) => {
88
88
const data = Buffer . from ( 'hello world' )
89
89
@@ -258,7 +258,7 @@ describe('pubsub', function () {
258
258
259
259
describe ( 'binary data' , ( ) => {
260
260
const data = Buffer . from ( 'a36161636179656162830103056164a16466666666f400010203040506070809' , 'hex' )
261
-
261
+
262
262
it ( 'publish from Go, subscribe on Go' , ( done ) => {
263
263
const topic = 'pubsub-binary-go-go'
264
264
let n = 0
You can’t perform that action at this time.
0 commit comments