Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Fix issue #45 #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ const errors = require('./errors')
const transports = require('./transports')
const utils = require('./utils')

function lookupLink (node, keys) {
for (let key of keys) {
function lookupLink (node, schemaKeys) {
for (let key of schemaKeys) {
if (node instanceof document.Document) {
node = node.content[key]
} else {
node = node[key]
}
if (node === undefined) {
throw new errors.LinkLookupError(`Invalid link lookup: ${JSON.stringify(keys)}`)
throw new errors.LinkLookupError(`Invalid link lookup: ${JSON.stringify(schemaKeys)}`)
}
}
if (!(node instanceof document.Link)) {
throw new errors.LinkLookupError(`Invalid link lookup: ${JSON.stringify(keys)}`)
throw new errors.LinkLookupError(`Invalid link lookup: ${JSON.stringify(schemaKeys)}`)
}
return node
}
Expand All @@ -34,8 +34,8 @@ class Client {
this.transports = options.transports || [new transports.HTTPTransport(transportOptions)]
}

action (document, keys, params = {}) {
const link = lookupLink(document, keys)
action (document, schemaKeys, params = {}) {
const link = lookupLink(document, schemaKeys)
const transport = utils.determineTransport(this.transports, link.url)
return transport.action(link, this.decoders, params)
}
Expand Down