Skip to content

Commit 0c56daa

Browse files
authored
Merge pull request #133 from sparksuite/get-accurate-byte-length
Utilized method of getting more accurate byte length
2 parents db1783d + 0fe971e commit 0c56daa

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "w3c-css-validator",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Easily validate CSS using W3C's public CSS validator service",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/retrieve-validation/browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const retrieveInBrowser = async (
2828
? {
2929
headers: {
3030
'Content-Type': `multipart/form-data; boundary=${parameters.slice(2, boundaryLength + 2)}`,
31-
'Content-Length': String(parameters.length),
31+
'Content-Length': String(new TextEncoder().encode(parameters).byteLength),
3232
},
3333
body: parameters,
3434
}

src/retrieve-validation/node.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as https from 'https';
33
import { W3CCSSValidatorResponse } from '.';
44
import BadStatusError from './bad-status-error';
55
import { boundaryLength } from './get-boundary';
6+
import { TextEncoder } from 'util';
67

78
// Utility function for retrieving response from W3C CSS Validator in a Node.js environment
89
const retrieveInNode = async (
@@ -21,7 +22,7 @@ const retrieveInNode = async (
2122
? {
2223
headers: {
2324
'Content-Type': `multipart/form-data; boundary=${parameters.slice(2, boundaryLength + 2)}`,
24-
'Content-Length': String(parameters.length),
25+
'Content-Length': String(new TextEncoder().encode(parameters).byteLength),
2526
},
2627
}
2728
: {}),

test-projects/browser/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
extensions: ['.ts', '.js'],
1616
fallback: {
1717
https: false,
18+
util: false,
1819
},
1920
},
2021
output: {

0 commit comments

Comments
 (0)