From ab811a0d0ba70b6d3ac27c0967f24cef918c47bd Mon Sep 17 00:00:00 2001 From: dark64 Date: Thu, 16 Jul 2020 11:10:13 +0200 Subject: [PATCH] fix import resolving issue with absolute paths --- zokrates_js/tests/tests.js | 7 ++++++- zokrates_js/wrapper.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/zokrates_js/tests/tests.js b/zokrates_js/tests/tests.js index edcfb9fc..d235e3c4 100644 --- a/zokrates_js/tests/tests.js +++ b/zokrates_js/tests/tests.js @@ -25,7 +25,12 @@ describe('tests', function() { it('should resolve stdlib module', function() { assert.doesNotThrow(() => { - const code = 'import "hashes/sha256/512bit" as sha256\ndef main() -> (): return'; + const code = ` + import "hashes/sha256/512bit" as sha256 + import "ecc/edwardsAdd" as edwardsAdd + def main() -> (): + return + `; this.zokrates.compile(code, "main"); }) }); diff --git a/zokrates_js/wrapper.js b/zokrates_js/wrapper.js index e163c128..7765e0c2 100644 --- a/zokrates_js/wrapper.js +++ b/zokrates_js/wrapper.js @@ -1,4 +1,7 @@ const getAbsolutePath = (basePath, relativePath) => { + if (relativePath[0] !== '.') { + return relativePath; + } var stack = basePath.split('/'); var chunks = relativePath.split('/'); stack.pop();