| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ function check(request) { | |||
| 32 | 32 | ||
| 33 | 33 | const server = http.createServer(function(request, response) { | |
| 34 | 34 | // run the check function | |
| 35 | - check.call(this, request, response); | ||
| 35 | + check(request); | ||
| 36 | 36 | response.writeHead(200, {}); | |
| 37 | 37 | response.end('ok'); | |
| 38 | 38 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ function check(request) { | |||
| 32 | 32 | ||
| 33 | 33 | const server = http.createServer(function(request, response) { | |
| 34 | 34 | // run the check function | |
| 35 | - check.call(this, request, response); | ||
| 35 | + check(request); | ||
| 36 | 36 | response.writeHead(200, {}); | |
| 37 | 37 | response.end('ok'); | |
| 38 | 38 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,7 @@ function check(request) { | |||
| 40 | 40 | ||
| 41 | 41 | const server = http.createServer(function(request, response) { | |
| 42 | 42 | // run the check function | |
| 43 | - check.call(this, request, response); | ||
| 43 | + check(request); | ||
| 44 | 44 | response.writeHead(200, {}); | |
| 45 | 45 | response.end('ok'); | |
| 46 | 46 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ function check(request) { | |||
| 42 | 42 | ||
| 43 | 43 | const server = https.createServer(httpsOptions, function(request, response) { | |
| 44 | 44 | // run the check function | |
| 45 | - check.call(this, request, response); | ||
| 45 | + check(request); | ||
| 46 | 46 | response.writeHead(200, {}); | |
| 47 | 47 | response.end('ok'); | |
| 48 | 48 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,68 +20,25 @@ | |||
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | - require('../common'); | ||
| 24 | - const assert = require('assert'); | ||
| 23 | + const common = require('../common'); | ||
| 25 | 24 | const http = require('http'); | |
| 26 | 25 | const url = require('url'); | |
| 27 | 26 | ||
| 28 | - | ||
| 29 | - assert.throws(function() { | ||
| 30 | - http.request(url.parse('file:///whatever')); | ||
| 31 | - }, function(err) { | ||
| 32 | - if (err instanceof Error) { | ||
| 33 | - assert.strictEqual( | ||
| 34 | - err.message, 'Protocol "file:" not supported. Expected "http:"'); | ||
| 35 | - return true; | ||
| 36 | - } | ||
| 37 | - }); | ||
| 38 | - | ||
| 39 | - assert.throws(function() { | ||
| 40 | - http.request(url.parse('mailto:asdf@asdf.com')); | ||
| 41 | - }, function(err) { | ||
| 42 | - if (err instanceof Error) { | ||
| 43 | - assert.strictEqual( | ||
| 44 | - err.message, 'Protocol "mailto:" not supported. Expected "http:"'); | ||
| 45 | - return true; | ||
| 46 | - } | ||
| 47 | - }); | ||
| 48 | - | ||
| 49 | - assert.throws(function() { | ||
| 50 | - http.request(url.parse('ftp://www.example.com')); | ||
| 51 | - }, function(err) { | ||
| 52 | - if (err instanceof Error) { | ||
| 53 | - assert.strictEqual( | ||
| 54 | - err.message, 'Protocol "ftp:" not supported. Expected "http:"'); | ||
| 55 | - return true; | ||
| 56 | - } | ||
| 57 | - }); | ||
| 58 | - | ||
| 59 | - assert.throws(function() { | ||
| 60 | - http.request(url.parse('javascript:alert(\'hello\');')); | ||
| 61 | - }, function(err) { | ||
| 62 | - if (err instanceof Error) { | ||
| 63 | - assert.strictEqual( | ||
| 64 | - err.message, 'Protocol "javascript:" not supported. Expected "http:"'); | ||
| 65 | - return true; | ||
| 66 | - } | ||
| 67 | - }); | ||
| 68 | - | ||
| 69 | - assert.throws(function() { | ||
| 70 | - http.request(url.parse('xmpp:isaacschlueter@jabber.org')); | ||
| 71 | - }, function(err) { | ||
| 72 | - if (err instanceof Error) { | ||
| 73 | - assert.strictEqual( | ||
| 74 | - err.message, 'Protocol "xmpp:" not supported. Expected "http:"'); | ||
| 75 | - return true; | ||
| 76 | - } | ||
| 77 | - }); | ||
| 78 | - | ||
| 79 | - assert.throws(function() { | ||
| 80 | - http.request(url.parse('f://some.host/path')); | ||
| 81 | - }, function(err) { | ||
| 82 | - if (err instanceof Error) { | ||
| 83 | - assert.strictEqual( | ||
| 84 | - err.message, 'Protocol "f:" not supported. Expected "http:"'); | ||
| 85 | - return true; | ||
| 86 | - } | ||
| 27 | + const invalidUrls = [ | ||
| 28 | + 'file:///whatever', | ||
| 29 | + 'mailto:asdf@asdf.com', | ||
| 30 | + 'ftp://www.example.com', | ||
| 31 | + 'javascript:alert(\'hello\');', | ||
| 32 | + 'xmpp:foo@bar.com', | ||
| 33 | + 'f://some.host/path' | ||
| 34 | + ]; | ||
| 35 | + | ||
| 36 | + invalidUrls.forEach((invalid) => { | ||
| 37 | + common.expectsError( | ||
| 38 | + () => { http.request(url.parse(invalid)); }, | ||
| 39 | + { | ||
| 40 | + code: 'ERR_INVALID_PROTOCOL', | ||
| 41 | + type: Error | ||
| 42 | + } | ||
| 43 | + ); | ||
| 87 | 44 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ function check(request) { | |||
| 32 | 32 | ||
| 33 | 33 | const server = http.createServer(function(request, response) { | |
| 34 | 34 | // run the check function | |
| 35 | - check.call(this, request, response); | ||
| 35 | + check(request); | ||
| 36 | 36 | response.writeHead(200, {}); | |
| 37 | 37 | response.end('ok'); | |
| 38 | 38 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ function check(request) { | |||
| 39 | 39 | ||
| 40 | 40 | const server = http.createServer(function(request, response) { | |
| 41 | 41 | // run the check function | |
| 42 | - check.call(this, request, response); | ||
| 42 | + check(request); | ||
| 43 | 43 | response.writeHead(200, {}); | |
| 44 | 44 | response.end('ok'); | |
| 45 | 45 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ function check(request) { | |||
| 32 | 32 | ||
| 33 | 33 | const server = http.createServer(function(request, response) { | |
| 34 | 34 | // run the check function | |
| 35 | - check.call(this, request, response); | ||
| 35 | + check(request); | ||
| 36 | 36 | response.writeHead(200, {}); | |
| 37 | 37 | response.end('ok'); | |
| 38 | 38 | server.close(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments