-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cagov/hypermedia-api
HTML-based API response
- Loading branch information
Showing
10 changed files
with
172 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,8 @@ | |
}, | ||
"workspaces": [ | ||
"widget" | ||
] | ||
], | ||
"volta": { | ||
"node": "18.17.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const url = require("./url"); | ||
|
||
/** | ||
* Find the host definition for a given host url. | ||
* We want to match up the origin of the request (host) with our own metadata (hostDefs). | ||
* @param {string} host | ||
* The host page, as a URL (string), from which the widget sent this request. | ||
* @param {import('./s3.js').Host[]} hostDefs | ||
* A list of host objects from the Airtable-derived definitions. | ||
* @returns {import('./s3.js').Host|undefined} | ||
* A matching host definition, or undefined if none are found. | ||
*/ | ||
exports.matchHostDef = (host, hostDefs) => { | ||
const pHostUrl = url.parse(host); | ||
|
||
if (pHostUrl && hostDefs) { | ||
return hostDefs.find((hostDef) => | ||
hostDef.urls.some((hostDefUrl) => { | ||
const pHostDefUrl = url.parse(hostDefUrl); | ||
return pHostDefUrl.hostname === pHostUrl.hostname; | ||
}) | ||
); | ||
} else { | ||
return undefined; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.