From bdea0884dcc06ca868ca56ff853fa2c5d97c445a Mon Sep 17 00:00:00 2001 From: Thim Date: Sun, 18 Aug 2024 17:05:17 +0200 Subject: [PATCH 1/3] Use K6 encoding --- lib/common/feature.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/common/feature.js b/lib/common/feature.js index a9cf107..31f26b3 100644 --- a/lib/common/feature.js +++ b/lib/common/feature.js @@ -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) { From c5bbe3dec3f72cb89dd296af8a07ce21a9b600be Mon Sep 17 00:00:00 2001 From: Thim Date: Sun, 18 Aug 2024 18:22:41 +0200 Subject: [PATCH 2/3] Implement Atob via K6 encoding --- lib/shim/atob.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lib/shim/atob.js diff --git a/lib/shim/atob.js b/lib/shim/atob.js new file mode 100644 index 0000000..5bf9faa --- /dev/null +++ b/lib/shim/atob.js @@ -0,0 +1,6 @@ +import { b64decode } from 'k6/encoding'; +function atob(str) { + return b64decode(str, 'std', 's'); +} + +global.atob = atob; From 8ab38e074f9d5e265e3970400e3b99d3ac7dbcd7 Mon Sep 17 00:00:00 2001 From: Thim Date: Sun, 18 Aug 2024 18:24:41 +0200 Subject: [PATCH 3/3] Implement Atob via K6 encoding --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd66c36..fbf78c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) + ## [1.12.0] - 2024-07-31 - Fix initialization of headers for each K6 request (#98)