1.0.0 • Published 11 years ago
http-s v1.0.0
http-s
A Node module to load the http or https module accordingly to the protocol name
var httpOrHttps = require('http-s');
httpOrHttps('http://nodejs.org/'); // equivalent of `require('http')`
httpOrHttps('https://www.npmjs.com/'); // equivalent of `require('https')`
httpOrHttps({protocol: 'http:'}); // equivalent of `require('http')`Installation
npm
npm install http-sbower
bower install http-sAPI
var httpOrHttps = require('http-s');httpOrHttps(urlObject)
urlObject: Object (which has protocol property)
Return: http or https
It returns http module if the protocol property is "http:", or returns https module if the property is "https:".
httpOrHttps({protocol: 'https:'}); //=> https
var url = require('url');
var options = url.parse('http://nodejs.org/api/url.html');
// => {protocol: 'http:', slashes: true, auth: null, ...}
httpOrHttps(options); //=> httphttpOrHttps(urlString)
urlString: String
Return: http or https
When it takes a string as an argument instead of an object, it automatically parses the string with url.parse().
httpOrHttps('http://nodeschool.io/'); //=> httpLicense
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.