mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
PR-URL: https://github.com/nodejs/node/pull/12992 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Luca Maraschi <luca.maraschi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const url = require('url');
|
|
|
|
|
|
assert.throws(function() {
|
|
http.request(url.parse('file:///whatever'));
|
|
}, function(err) {
|
|
if (err instanceof Error) {
|
|
assert.strictEqual(
|
|
err.message, 'Protocol "file:" not supported. Expected "http:"');
|
|
return true;
|
|
}
|
|
});
|
|
|
|
assert.throws(function() {
|
|
http.request(url.parse('mailto:asdf@asdf.com'));
|
|
}, function(err) {
|
|
if (err instanceof Error) {
|
|
assert.strictEqual(
|
|
err.message, 'Protocol "mailto:" not supported. Expected "http:"');
|
|
return true;
|
|
}
|
|
});
|
|
|
|
assert.throws(function() {
|
|
http.request(url.parse('ftp://www.example.com'));
|
|
}, function(err) {
|
|
if (err instanceof Error) {
|
|
assert.strictEqual(
|
|
err.message, 'Protocol "ftp:" not supported. Expected "http:"');
|
|
return true;
|
|
}
|
|
});
|
|
|
|
assert.throws(function() {
|
|
http.request(url.parse('javascript:alert(\'hello\');'));
|
|
}, function(err) {
|
|
if (err instanceof Error) {
|
|
assert.strictEqual(
|
|
err.message, 'Protocol "javascript:" not supported. Expected "http:"');
|
|
return true;
|
|
}
|
|
});
|
|
|
|
assert.throws(function() {
|
|
http.request(url.parse('xmpp:isaacschlueter@jabber.org'));
|
|
}, function(err) {
|
|
if (err instanceof Error) {
|
|
assert.strictEqual(
|
|
err.message, 'Protocol "xmpp:" not supported. Expected "http:"');
|
|
return true;
|
|
}
|
|
});
|
|
|
|
assert.throws(function() {
|
|
http.request(url.parse('f://some.host/path'));
|
|
}, function(err) {
|
|
if (err instanceof Error) {
|
|
assert.strictEqual(
|
|
err.message, 'Protocol "f:" not supported. Expected "http:"');
|
|
return true;
|
|
}
|
|
});
|