Skip to content

Commit bf5541c

Browse files
authored
Merge pull request #1158 from solid/fix/#1011
Fixed JSON not being written to file
2 parents 71aae25 + 7835303 commit bf5541c

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
/data
1515
/coverage
1616
/node_modules
17-
/npm-debug.log
17+
/npm-debug.log

lib/ldp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { join, dirname } = require('path')
2+
const intoStream = require('into-stream')
23
const url = require('url')
34
const fs = require('fs')
45
const $rdf = require('rdflib')
@@ -160,6 +161,13 @@ class LDP {
160161
}
161162
const { url: putUrl, contentType } = await this.resourceMapper.mapFileToUrl(
162163
{ path: this.resourceMapper.rootPath + resourcePath, hostname: host })
164+
165+
// HACK: the middleware in webid-oidc.js uses body-parser, thus ending the stream of data
166+
// for JSON bodies. So, the stream needs to be reset
167+
if (contentType.includes('application/json')) {
168+
stream = intoStream(JSON.stringify(stream.body))
169+
}
170+
163171
await ldp.put(putUrl, stream, contentType)
164172
return originalPath
165173
}

package-lock.json

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"homepage": "https://github.com/solid/node-solid-server",
5656
"bugs": "https://github.com/solid/node-solid-server/issues",
5757
"dependencies": {
58-
"@solid/oidc-auth-manager": "^0.17.1",
5958
"@solid/acl-check": "^0.2.0",
59+
"@solid/oidc-auth-manager": "^0.17.1",
6060
"body-parser": "^1.18.3",
6161
"bootstrap": "^3.3.7",
6262
"busboy": "^0.2.12",
@@ -79,6 +79,7 @@
7979
"handlebars": "^4.0.13",
8080
"http-proxy-middleware": "^0.18.0",
8181
"inquirer": "^1.0.2",
82+
"into-stream": "^5.0.0",
8283
"ip-range-check": "0.0.2",
8384
"is-ip": "^2.0.0",
8485
"li": "^1.0.1",

0 commit comments

Comments
 (0)