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

Correctly calculate byte size of the utf8 strings #291

Merged
merged 1 commit into from
May 16, 2022

Conversation

jstastny
Copy link
Contributor

The original implementation started causing problems when the webdav client was used in combination with axios 0.22 and later, as in 0.22 axios started considering the Content-Length passed in the request where it previously ignored it and calculated the length on its own.

The original implementation started causing problems when the webdav client was used in combination with axios 0.22 and later, as in 0.22 axios started considering the `Content-Length` passed in the request axios/axios@f3ca637#diff-586c04c24608b86a074073c5514cc195be5c4c87ddb56da233f6d998ada4159fL85 where it previously ignored it and calculated the length on its own.
@@ -9,7 +9,7 @@ export function calculateDataLength(data: string | BufferLike): number {
} else if (isBuffer(data)) {
return (<Buffer>data).length;
} else if (typeof data === "string") {
return (<string>data).length;
return Buffer.byteLength(<string>data);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this won't work, as Buffer is not available in the web build.

@perry-mitchell perry-mitchell changed the base branch from master to byte-size May 16, 2022 03:27
@perry-mitchell
Copy link
Owner

Seeing as I didn't get any response, I'll merge and modify this fix to use a library which covers byte-size calculations.

@perry-mitchell perry-mitchell merged commit cb9e9c1 into perry-mitchell:byte-size May 16, 2022
perry-mitchell added a commit that referenced this pull request May 16, 2022
@jstastny
Copy link
Contributor Author

Hi.

Sorry for not responding. I stopped hoping that this could go live as is, so I've given up.

Thanks for taking the extra step to make it compatible with browser.

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

Successfully merging this pull request may close these issues.

2 participants