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
13
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 2.1.0 to 2.2.0

13

index.js

@@ -11,2 +11,6 @@ var _ = require('lodash');

adminOnly: true,
// Default type being joined for internal redirects.
// Can be overwritten project level with an array of
// multiple piece types: ex: [ 'apostrophe-page', 'news', 'people' ]
withType: 'apostrophe-page',
// Default status code. Must be one of the valid choices

@@ -68,3 +72,3 @@ // for the `statusCode` select field

filters: {
projection: { slug: 1, title: 1 },
projection: { slug: 1, title: 1, _url: 1 },
// Admins set up redirects, so it's OK for non-admins to follow them anywhere

@@ -108,3 +112,6 @@ // (they won't actually get access without logging in)

beforeConstruct: function(self, options) {
beforeConstruct: function (self, options) {
var _newPage = _.find(options.addFields, { name: '_newPage' });
_newPage.withType = options.withType;
var field = _.find(options.addFields, { name: 'statusCode' });

@@ -157,3 +164,3 @@ if (!field) {

if (result.urlType === 'internal' && result._newPage) {
return req.res.redirect(status, result._newPage.slug);
return req.res.redirect(status, result._newPage._url);
} else if (result.urlType === 'external' && result.externalUrl.length) {

@@ -160,0 +167,0 @@ return req.res.redirect(status, result.externalUrl);

{
"name": "apostrophe-redirects",
"version": "2.1.0",
"version": "2.2.0",
"description": "Allows admins to create redirects within an Apostrophe site",

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

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

Be aware that each redirect is live as soon as you save it and that it is possible to make a mess with redirects. In a pinch, you can remove unwanted redirects via the MongoDB command line client (see the `aposRedirects` collection).
Be aware that each redirect is live as soon as you save it and that it is possible to make a mess with redirects. In a pinch, you can remove unwanted redirects via the MongoDB command line client (look for `{ type: "apostrophe-redirect" }` in the `aposDocs` collection in MongoDB).
Also be aware that Apostrophe already creates "soft redirects" every time you change the slug of a page. So you shouldn't need manually created "hard redirects" in that situation.
## Advanced configuration with pieces
If you have pieces on your site and you would like to make a safer more persistent redirect that will update if your redirect destination changes, you can use polymorphic joins. To do this you need to add your piece(s) when configuring the module:
```javascript
'apostrophe-redirects': {
withType: ['apostrophe-page', 'product']
}
```
Note: When adding your own pieces, you should always define `apostrophe-page` to still make it possible to redirect to any normal page. Also note that your piece is written in singular and that you must have a suitable apostrophe-pieces-page for your piece (that is, it must have a `._url` property when Apostrophe fetches it). Refer to the core documentation for [reusable content with pieces](https://apostrophecms.org/docs/tutorials/getting-started/reusable-content-with-pieces.html#displaying-a-directory-of-people-on-a-page-with-code-apostrophe-pieces-pages-code).
Now when you create a new redirect, you have the option to browse for both pages and your pieces in the Apostrophe admin UI.
## Changelog
2.2.0 Implemented polymorphic joins for internal pages which also makes it possible to configure your own pieces for polymorphic joins.
2.1.0 Disables `apostrophe-site-map` for redirects to prevent more superfluous UI tabs.

@@ -57,0 +73,0 @@

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