🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ax2/redirect-ssl

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ax2/redirect-ssl - npm Package Compare versions

Comparing version
1.0.1
to
1.1.0
+10
-0
CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="1.1.0"></a>
# [1.1.0](https://github.com/ax2inc/redirect-ssl/compare/v1.0.1...v1.1.0) (2018-07-06)
### Features
* Add exclude option to disable redirection on specific route patterns ([302a8ed](https://github.com/ax2inc/redirect-ssl/commit/302a8ed))
<a name="1.0.1"></a>

@@ -7,0 +17,0 @@ ## [1.0.1](https://github.com/ax2inc/redirect-ssl/compare/v1.0.0...v1.0.1) (2018-07-04)

+11
-2

@@ -11,8 +11,17 @@ const isHTTPS = require('is-https');

redirect: process.env.NODE_ENV === 'production',
exclude: [],
};
const isIgnored = (url, patterns = []) => patterns.some(pattern => url.match(pattern));
// Creates new middleware using provided options
function create(options) {
const {
xForwardedProto, redirectPort, redirectHost, statusCode, redirectUnknown, redirect,
xForwardedProto,
redirectPort,
redirectHost,
statusCode,
redirectUnknown,
redirect,
exclude,
} = Object.assign({}, defaults, options);

@@ -23,3 +32,3 @@ const port = redirectPort === 443 ? '' : (`: ${redirectPort}`);

const { req, res } = ctx;
if (redirect) {
if (redirect && !isIgnored(req.url, exclude)) {
const isHttpsReq = isHTTPS(req, xForwardedProto);

@@ -26,0 +35,0 @@ const shouldRedirect = isHttpsReq === false || (redirectUnknown && isHttpsReq === null);

+1
-1
{
"name": "@ax2/redirect-ssl",
"version": "1.0.1",
"version": "1.1.0",
"description": "Enforce HTTPS on your Nuxt app with Koa backend",

@@ -5,0 +5,0 @@ "main": "index.js",