From 5b357f2c7aa4643964534d88ebe5db3512048a71 Mon Sep 17 00:00:00 2001 From: Dimitri Date: Fri, 13 Dec 2024 14:39:48 +0700 Subject: [PATCH] feat: accept snake_case and camelCase for wasm bindings --- packages/apis/src/extract_substrs.rs | 2 ++ packages/apis/tests/extract_substr.test.js | 42 +++++++++++----------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/packages/apis/src/extract_substrs.rs b/packages/apis/src/extract_substrs.rs index b805f8c..276d2db 100644 --- a/packages/apis/src/extract_substrs.rs +++ b/packages/apis/src/extract_substrs.rs @@ -12,8 +12,10 @@ pub struct DecomposedRegexConfig { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct RegexPartConfig { /// A flag indicating whether the substring matching with `regex_def` should be exposed. + #[serde(alias = "isPublic")] pub is_public: bool, /// A regex string. + #[serde(alias = "regexDef")] pub regex_def: String, } diff --git a/packages/apis/tests/extract_substr.test.js b/packages/apis/tests/extract_substr.test.js index 6e08c17..2f7991e 100644 --- a/packages/apis/tests/extract_substr.test.js +++ b/packages/apis/tests/extract_substr.test.js @@ -8,8 +8,8 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: true, - regex_def: 'Hello' + isPublic: true, + regexDef: 'Hello' } ] }; @@ -22,12 +22,12 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: true, - regex_def: 'Hello ' + isPublic: true, + regexDef: 'Hello ' }, { - is_public: false, - regex_def: 'guys!' + isPublic: false, + regexDef: 'guys!' } ] }; @@ -40,12 +40,12 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: true, - regex_def: 'Hello ' + isPublic: true, + regexDef: 'Hello ' }, { - is_public: false, - regex_def: 'guys!' + isPublic: false, + regexDef: 'guys!' } ] }; @@ -59,8 +59,8 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: false, - regex_def: 'Hello' + isPublic: false, + regexDef: 'Hello' } ] }; @@ -106,7 +106,7 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: false + isPublic: false } ] }; @@ -123,12 +123,12 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: true, - regex_def: 'Hello' + isPublic: true, + regexDef: 'Hello' }, { - is_public: false, - regex_def: 'yall!' + isPublic: false, + regexDef: 'yall!' } ] }; @@ -148,8 +148,8 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: true, - regex_def: 'Hello' + isPublic: true, + regexDef: 'Hello' } ] }; @@ -161,8 +161,8 @@ describe('Extract substr test suite', async () => { const parts = { parts: [ { - is_public: false, - regex_def: 'Hello' + isPublic: false, + regexDef: 'Hello' } ] };