ml-testing-toolkit 18.15.1-url-handling.0 → 18.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/lib/utils.js +15 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
|
|
2
|
+
### [18.15.1](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.15.0...v18.15.1) (2025-09-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* load mock definition from URL ([#340](https://github.com/mojaloop/ml-testing-toolkit/issues/340)) ([a3b96c8](https://github.com/mojaloop/ml-testing-toolkit/commit/a3b96c8907bdda174f10e308a964c9c6c0c667ce))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Chore
|
|
11
|
+
|
|
12
|
+
* **sbom:** update sbom [skip ci] ([1674a29](https://github.com/mojaloop/ml-testing-toolkit/commit/1674a297464bad8740c963835f73c7dc0cb31f42))
|
|
13
|
+
|
|
2
14
|
## [18.15.0](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.14.4...v18.15.0) (2025-08-21)
|
|
3
15
|
|
|
4
16
|
|
package/package.json
CHANGED
package/src/lib/utils.js
CHANGED
|
@@ -43,6 +43,7 @@ const readRecursiveAsync = promisify(files)
|
|
|
43
43
|
const rmdirAsync = promisify(fs.rmdir)
|
|
44
44
|
const mvAsync = promisify(mv)
|
|
45
45
|
const { resolve } = require('path')
|
|
46
|
+
const yaml = require('js-yaml')
|
|
46
47
|
|
|
47
48
|
const getHeader = (headers, name) => {
|
|
48
49
|
return Object.entries(headers).find(
|
|
@@ -80,9 +81,20 @@ const checkUrl = async fileName => {
|
|
|
80
81
|
await fileHandle.close()
|
|
81
82
|
}
|
|
82
83
|
const prefix = buffer.toString('utf8').replace('\uFEFF', '') // Remove BOM
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if (prefix.startsWith('"http') || prefix.startsWith("'http")) {
|
|
85
|
+
const content = fs.readFileSync(fileName, 'utf8')
|
|
86
|
+
try {
|
|
87
|
+
return JSON.parse(content)
|
|
88
|
+
} catch (jsonErr) {
|
|
89
|
+
try {
|
|
90
|
+
return yaml.load(content)
|
|
91
|
+
} catch (yamlErr) {
|
|
92
|
+
throw new Error(`Failed to parse file as JSON or YAML: ${jsonErr.message}; ${yamlErr.message}`)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
return fileName
|
|
97
|
+
}
|
|
86
98
|
}
|
|
87
99
|
|
|
88
100
|
module.exports = {
|