Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit fb04535

Browse files
committed
refactor: parse query strings in http-api endpoint
1 parent d5fa74e commit fb04535

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/core/runtime/dns-nodejs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const MAX_RECURSIVE_DEPTH = 32
99

1010
module.exports = (domain, opts, callback) => {
1111
// recursive is true by default, it's set to false only if explicitly passed as argument in opts
12-
const recursive = opts.recursive == null || opts.recursive.toString() !== 'false'
12+
const recursive = opts.recursive == null ? true : Boolean(opts.recursive)
1313

1414
let depth
1515
if (recursive) {

src/http/api/resources/dns.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
const Boom = require('boom')
44

55
module.exports = async (request, h) => {
6-
const { arg: domain, recursive, format } = request.query
6+
let { arg: domain, recursive, format } = request.query
77

88
if (!domain) {
99
throw Boom.badRequest("Argument 'domain' is required")
1010
}
1111

12+
// query parameters are passed as strings and need to be parsed to expected type
13+
recursive = !(recursive && recursive === 'false')
14+
1215
const path = await request.server.app.ipfs.dns(domain, { recursive, format })
1316
return h.response({
1417
Path: path

0 commit comments

Comments
 (0)