Skip to content

Commit 3d21bfe

Browse files
lucamaraschiMylesBorins
authored andcommitted
test: invalid chars in http client path
This test adds coverage for all the characters which are considered invalid in a http path. PR-URL: #11964 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e70ed3c commit 3d21bfe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const http = require('http');
5+
6+
const expectedError = /^TypeError: Request path contains unescaped characters$/;
7+
const theExperimentallyDeterminedNumber = 39;
8+
9+
function fail(path) {
10+
assert.throws(() => {
11+
http.request({ path }, common.fail);
12+
}, expectedError);
13+
}
14+
15+
for (let i = 0; i <= theExperimentallyDeterminedNumber; i++) {
16+
const prefix = 'a'.repeat(i);
17+
for (let i = 0; i <= 32; i++) {
18+
fail(prefix + String.fromCodePoint(i));
19+
}
20+
}

0 commit comments

Comments
 (0)