Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http Fix typo in util functions #888

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
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
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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

* 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
Loading