Skip to content

Commit

Permalink
Merge pull request #888 from OpenFn/http-utils
Browse files Browse the repository at this point in the history
`http` Fix typo in util functions
  • Loading branch information
josephjclark authored Jan 9, 2025
2 parents a47d8d5 + 17d1534 commit 7ca57d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/dull-peas-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@openfn/language-http': patch
---

- Fix typo in util functions examples
- Remove export for `addAuth()` helper
20 changes: 14 additions & 6 deletions packages/http/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import {
decode,
uuid,
} from '@openfn/language-common/util';

import * as cheerio from 'cheerio';
import cheerioTableparser from 'cheerio-tableparser';

export function addAuth(configuration, headers) {
function addAuth(configuration, headers) {
if (headers.Authorization) {
return;
}
Expand Down Expand Up @@ -52,6 +51,11 @@ const assertUrl = (pathOrUrl, baseUrl) => {
}
};

/**
* Request helper function
* @function
* @private
*/
export function request(method, path, params, callback = s => s) {
return state => {
const [resolvedPath, resolvedParams = {}] = expandReferences(
Expand Down Expand Up @@ -119,7 +123,11 @@ export function request(method, path, params, callback = s => s) {
});
};
}

/**
* XML parser helper function
* @function
* @private
*/
export function xmlParser(body, script, callback = s => s) {
return state => {
const [resolvedBody] = expandReferences(state, body);
Expand Down Expand Up @@ -148,7 +156,7 @@ export {
* @param {string} data - The string to be encoded.
* @returns {string} - The Base64 encoded string.
* @example <caption>Encode a string</caption>
* const encoded = Util.encode('Hello World');
* const encoded = util.encode('Hello World');
* console.log(encoded); // Output: SGVsbG8gV29ybGQ=
*/
encode,
Expand All @@ -159,7 +167,7 @@ export {
* @param {string} base64Data - The Base64 encoded string.
* @returns {string} - The decoded string.
* @example <caption>Decode a Base64 string</caption>
* const decoded = Util.decode('SGVsbG8gV29ybGQ=');
* const decoded = util.decode('SGVsbG8gV29ybGQ=');
* console.log(decoded); // Output: Hello World
*/
decode,
Expand All @@ -169,7 +177,7 @@ export {
* @public
* @returns {string} - A newly generated UUID.
* @example <caption>Generate a UUID</caption>
* const id = Util.uuid();
* const id = util.uuid();
* console.log(id); // Output:'3f4e254e-8f6f-4f8b-9651-1c1c262cc83f'
*/
uuid,
Expand Down

0 comments on commit 7ca57d3

Please sign in to comment.