New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apostrophe-redirects

Package Overview
Dependencies
Maintainers
11
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apostrophe-redirects - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

.editorconfig

43

index.js

@@ -34,3 +34,3 @@ module.exports = {

required: true
},
},
{

@@ -43,3 +43,3 @@ // contextual: true to hide this property

def: true,
contextual: true
contextual: true
},

@@ -54,3 +54,3 @@ {

]
},
},
{

@@ -61,3 +61,3 @@ name: '_newPage',

label: 'Page Title',
idField: 'pageId',
idField: 'pageId',
filters: {

@@ -69,3 +69,3 @@ projection: { slug: 1, title: 1 },

}
},
},
{

@@ -87,3 +87,3 @@ name: 'externalUrl',

'_newPage',
'externalUrl',
'externalUrl'
]

@@ -93,7 +93,5 @@ }

construct: function(self, options) {
var pages = self.apos.pages;
self.beforeSave = function(req, doc, options, callback) {
//prefix the actual slug so it's not treated as a page
construct: function (self, options) {
self.beforeSave = function (req, doc, options, callback) {
// prefix the actual slug so it's not treated as a page
doc.slug = 'redirect-' + doc.redirectSlug;

@@ -108,8 +106,6 @@

// ALL pages should check to see if a redirect exists
var superPagesServe = pages.serve;
pages.serve = function(req, res) {
// req.url rather than req.params[0], lets us match query strings
// Check to see if a redirect exists before sending user on their way
self.expressMiddleware = function (req, res, next) {
var slug = req.url;
return self.find(req, { slug: 'redirect-' + slug }, {
return self.find(req, { slug: 'redirect-' + slug }, {
title: 1,

@@ -123,14 +119,17 @@ slug: 1,

_newPage: 1
}).toObject(function(err, result) {
if(result) {
if(result.urlType == 'internal' && result._newPage) {
}).toObject(function (err, result) {
if (err) {
console.log(err);
}
if (result) {
if (result.urlType === 'internal' && result._newPage) {
return req.res.redirect(result._newPage.slug);
} else if(result.urlType == 'external' && result.externalUrl.length) {
} else if (result.urlType === 'external' && result.externalUrl.length) {
return req.res.redirect(result.externalUrl);
}
}
return superPagesServe(req, res);
return next();
});
};
}
}
};
{
"name": "apostrophe-redirects",
"version": "0.6.4",
"version": "0.6.5",
"description": "Allows admins to create redirects within an Apostrophe site",

@@ -23,4 +23,12 @@ "main": "index.js",

},
"dependencies": {
"devDependencies": {
"eslint": "^4.2.0",
"eslint-config-punkave": "^1.0.8",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-standard": "^3.0.1"
}
}

@@ -40,5 +40,6 @@ This module allows admins to add redirects from one URL to another within an [Apostrophe site](http://apostrophecms.org/).

0.6.5: Use express middleware instead of relying on `apos.pages.serve`. This lets redirects happen for files, etc.
0.6.1: the `redirectSlug` should be `type: 'string'` because the old site may have allowed nonsense in slugs that we do not allow. Also compare to `req.url` so query string matches are allowed.
0.6.0: initial release.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc