[Pkg-javascript-commits] [node-prepend-http] 01/04: New upstream version 2.0.0

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Tue Jan 30 13:26:05 UTC 2018


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository node-prepend-http.

commit 6cbf4e269aa7596a2909c261eddd921d191185ab
Author: Pirate Praveen <praveen at debian.org>
Date:   Tue Jan 30 18:49:03 2018 +0530

    New upstream version 2.0.0
---
 .editorconfig  |  2 +-
 .gitattributes |  1 +
 .gitignore     |  1 +
 .npmrc         |  1 +
 .travis.yml    |  4 +---
 index.js       |  7 ++++---
 license        | 20 ++++----------------
 package.json   |  4 ++--
 readme.md      | 27 ++++++++++++++++++++++++++-
 test.js        | 10 ++++++++--
 10 files changed, 49 insertions(+), 28 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 98a761d..1c6314a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,6 +7,6 @@ charset = utf-8
 trim_trailing_whitespace = true
 insert_final_newline = true
 
-[{package.json,*.yml}]
+[*.yml]
 indent_style = space
 indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index 176a458..391f0a4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
 * text=auto
+*.js text eol=lf
diff --git a/.gitignore b/.gitignore
index 3c3629e..239ecff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 node_modules
+yarn.lock
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..43c97e7
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/.travis.yml b/.travis.yml
index 2c6e9b0..7d69d74 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,5 @@
-sudo: false
 language: node_js
 node_js:
+  - '8'
   - '6'
   - '4'
-  - '0.12'
-  - '0.10'
diff --git a/index.js b/index.js
index 60f532a..82b3a6b 100644
--- a/index.js
+++ b/index.js
@@ -1,14 +1,15 @@
 'use strict';
-module.exports = function (url) {
+module.exports = (url, opts) => {
 	if (typeof url !== 'string') {
-		throw new TypeError('Expected a string, got ' + typeof url);
+		throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof url}\``);
 	}
 
 	url = url.trim();
+	opts = Object.assign({https: false}, opts);
 
 	if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
 		return url;
 	}
 
-	return url.replace(/^(?!(?:\w+:)?\/\/)/, 'http://');
+	return url.replace(/^(?!(?:\w+:)?\/\/)/, opts.https ? 'https://' : 'http://');
 };
diff --git a/license b/license
index 654d0bf..e7af2f7 100644
--- a/license
+++ b/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
 
 Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/package.json b/package.json
index 75954f7..cbfac02 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "prepend-http",
-  "version": "1.0.4",
+  "version": "2.0.0",
   "description": "Prepend `http://` to humanized URLs like todomvc.com and localhost",
   "license": "MIT",
   "repository": "sindresorhus/prepend-http",
@@ -10,7 +10,7 @@
     "url": "sindresorhus.com"
   },
   "engines": {
-    "node": ">=0.10.0"
+    "node": ">=4"
   },
   "scripts": {
     "test": "xo && ava"
diff --git a/readme.md b/readme.md
index df7557e..55d640d 100644
--- a/readme.md
+++ b/readme.md
@@ -6,7 +6,7 @@
 ## Install
 
 ```
-$ npm install --save prepend-http
+$ npm install prepend-http
 ```
 
 
@@ -23,9 +23,34 @@ prependHttp('localhost');
 
 prependHttp('http://todomvc.com');
 //=> 'http://todomvc.com'
+
+prependHttp('todomvc.com', {https: true});
+//=> 'https://todomvc.com'
 ```
 
 
+## API
+
+### prependHttp(url, [options])
+
+#### url
+
+Type: `string`
+
+URL to prepend `http://` on.
+
+#### options
+
+Type: `Object`
+
+##### https
+
+Type: `boolean`<br>
+Default: `false`
+
+Prepend `https://` instead of `http://`.
+
+
 ## License
 
 MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/test.js b/test.js
index bc0bcad..7a9040d 100644
--- a/test.js
+++ b/test.js
@@ -1,7 +1,7 @@
 import test from 'ava';
-import m from './';
+import m from '.';
 
-test(t => {
+test('prepend http', t => {
 	t.is(m('todomvc.com'), 'http://todomvc.com');
 	t.is(m('http://todomvc.com'), 'http://todomvc.com');
 	t.is(m('https://todomvc.com'), 'https://todomvc.com');
@@ -15,3 +15,9 @@ test(t => {
 	t.is(m('mailto:info at site.com'), 'mailto:info at site.com');
 	t.is(m('tel:1234567890'), 'tel:1234567890');
 });
+
+test('https option', t => {
+	t.is(m('todomvc.com', {https: true}), 'https://todomvc.com');
+	t.is(m('//todomvc.com', {https: true}), '//todomvc.com');
+	t.is(m('localhost:8000', {https: true}), 'https://localhost:8000');
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-prepend-http.git



More information about the Pkg-javascript-commits mailing list