Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 Don't transform number keys #54

Merged
merged 4 commits into from
Feb 21, 2023
Merged

Conversation

mpyw
Copy link
Owner

@mpyw mpyw commented Feb 21, 2023

It might be broken if you customized snake-case functions.

const client = applyCaseMiddleware(axios.create(), {
    caseFunctions: {
        snake: (s) => s.replace(/[A-Z]|\d+/g, (s) => `_${s.toLowerCase()}`),
    },
});

cleint.post({ data: ['X', 'Y']});

The code above actually sends {"data": []} instead of {"data": ["X", "Y"]}because it transforms

Array { 0: 'X', 1: 'Y', length: 2 }

into

Array { '_0': 'X', '_1': 'Y', length: 2 }

@mpyw mpyw self-assigned this Feb 21, 2023
@mpyw mpyw added the bug label Feb 21, 2023
@mpyw mpyw merged commit 44034a6 into master Feb 21, 2023
mpyw added a commit that referenced this pull request Feb 21, 2023
Note that `axios:^0` support has been removed
@mpyw mpyw deleted the fix/array-index-broken branch February 21, 2023 13:27
mpyw added a commit that referenced this pull request Feb 21, 2023
`Object.entires()` always yields string for number keys

✅ Closes: #54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant