Skip to content

Commit

Permalink
Implement atob via K6 encoding (#139)
Browse files Browse the repository at this point in the history
* Implement atob via K6 encoding
  • Loading branch information
thim81 authored Aug 18, 2024
1 parent d197c6e commit 21227dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/apideck-libraries/postman-to-k6/compare/v1.8.7...HEAD)


- Implement Atob via K6 encoding (#86)
- Extended pm.request with support for headers, url, method, name, id, body, body.raw

## [1.12.0] - 2024-07-31
Expand Down
9 changes: 9 additions & 0 deletions lib/common/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ function detectFeature(logic, result) {
result.polyfills.add('spo-gpo');
result.effectImports.add(xml2JsonPath);
}

if (/\batob\b/.test(logic)) {
let atobPath = './libs/shim/atob.js';
if (result?.setting?.separate === true) {
const pathDepth = renderDirectoryPathGroup(result.group);
atobPath = `${pathDepth}libs/shim/atob.js`;
}
result.effectImports.add(atobPath);
}
}

function renderDirectoryPathGroup(group) {
Expand Down
6 changes: 6 additions & 0 deletions lib/shim/atob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { b64decode } from 'k6/encoding';
function atob(str) {
return b64decode(str, 'std', 's');
}

global.atob = atob;

0 comments on commit 21227dd

Please sign in to comment.