Infer contextUrl through documentation scheme + host if spec url is relative

This commit is contained in:
Kyle Shockey
2017-04-07 20:51:07 -07:00
parent 5f9efc09cb
commit e2b1757f8f
6 changed files with 50 additions and 44 deletions

View File

@@ -1,4 +1,5 @@
import YAML from "js-yaml"
import parseUrl from "url-parse"
import serializeError from "serialize-error"
// Actions conform to FSA (flux-standard-actions)
@@ -186,7 +187,11 @@ export const logRequest = (req) => {
// (For debugging) and ease of testing
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
let { pathName, method } = req
let parsedRequest = Object.assign({ contextUrl: specSelectors.url() }, req)
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
let specUrl = parseUrl(specSelectors.url())
let parsedRequest = Object.assign({ contextUrl: specUrl.toString() }, req)
if ( pathName && method ) {
parsedRequest.operationId = method.toLowerCase() + "-" + pathName
}