mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Added JSDocs to redirects validator
refs https://github.com/TryGhost/Toolbox/issues/139 - Makes the expected file formatting easier to reason about
This commit is contained in:
parent
6ed5f64f4b
commit
b807be9699
@ -217,7 +217,7 @@ class CustomRedirectsAPI {
|
||||
const redirectsFilePath = await this.getRedirectsFilePath();
|
||||
|
||||
if (redirectsFilePath) {
|
||||
const backupRedirectsPath = getBackupRedirectsFilePath(redirectsFilePath);
|
||||
const backupRedirectsPath = this.getBackupFilePath(redirectsFilePath);
|
||||
|
||||
const backupExists = await fs.pathExists(backupRedirectsPath);
|
||||
if (backupExists) {
|
||||
|
@ -7,9 +7,19 @@ const messages = {
|
||||
invalidRedirectsFromRegex: 'Incorrect RegEx in redirects file.',
|
||||
redirectsHelp: 'https://ghost.org/docs/themes/routing/#redirects'
|
||||
};
|
||||
|
||||
/**
|
||||
* Redirect configuration object
|
||||
* @typedef {Object} RedirectConfig
|
||||
* @property {String} from - Defines the relative incoming URL or pattern (regex)
|
||||
* @property {String} to - Defines where the incoming traffic should be redirected to, which can be a static URL, or a dynamic value using regex (example: "to": "/$1/")
|
||||
* @property {boolean} [permanent] - Can be defined with true for a permanent HTTP 301 redirect, or false for a temporary HTTP 302 redirect
|
||||
*/
|
||||
|
||||
/**
|
||||
* Redirects are file based at the moment, but they will live in the database in the future.
|
||||
* See V2 of https://github.com/TryGhost/Ghost/issues/7707.
|
||||
* @param {RedirectConfig[]} redirects
|
||||
*/
|
||||
const validate = (redirects) => {
|
||||
if (!_.isArray(redirects)) {
|
||||
|
Loading…
Reference in New Issue
Block a user