Skip to content

Commit

Permalink
test: invalid chars in http client path
Browse files Browse the repository at this point in the history
This test adds coverage for all the characters which are considered
invalid in a http path.

PR-URL: #11964
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lucamaraschi authored and MylesBorins committed Mar 28, 2017
1 parent e70ed3c commit 3d21bfe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/parallel/test-http-invalid-path-chars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');

const expectedError = /^TypeError: Request path contains unescaped characters$/;
const theExperimentallyDeterminedNumber = 39;

function fail(path) {
assert.throws(() => {
http.request({ path }, common.fail);
}, expectedError);
}

for (let i = 0; i <= theExperimentallyDeterminedNumber; i++) {
const prefix = 'a'.repeat(i);
for (let i = 0; i <= 32; i++) {
fail(prefix + String.fromCodePoint(i));
}
}

0 comments on commit 3d21bfe

Please sign in to comment.