Skip to content

Commit e7e0d59

Browse files
author
Miel Vander Sande
committed
Added https support
1 parent bf5db31 commit e7e0d59

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

TurtleValidator.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
var N3 = require('n3'),
77
fs = require('fs'),
88
N3Util = N3.Util,
9-
http = require('http'),
9+
http = require('http');
1010
url = require('url'),
1111
fs = require('fs'),
1212
validate = require('./lib/validator.js');
@@ -34,14 +34,22 @@ if (args.length === 0) {
3434
} else if (args.length > 0) {
3535
// Create a stream from the file, whether it is a local file or a http stream
3636
var parsedUrl = url.parse(args[0]);
37-
if (parsedUrl.protocol === 'http:')
37+
switch (parsedUrl.protocol) {
38+
case 'https:':
39+
http = require('https');
40+
case 'http:':
3841
http.get(parsedUrl.href, function (res) {
3942
validate(res, showValidation);
4043
}).on('error', function (e) {
4144
console.log("Got error: " + e.message);
4245
});
43-
else
46+
break;
47+
case null:
4448
validate(fs.createReadStream(parsedUrl.href), showValidation);
49+
break;
50+
default:
51+
console.log('Cannot access %s: "%s" not supported', parsedUrl.href, parsedUrl.protocol)
52+
}
4553
}
4654

4755
// Use stdio as an input stream

0 commit comments

Comments
 (0)