mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +00:00
2fa397548a
* feat/navigate upgrade react router * feat/navigate migrate to react router 6 * feat/navigate style modal * feat/navigate create endpoints for app settings * feat/navigate protect editor with pin * feat/navigate apply dynamic routing draft * feat/navigate upgrade relevant packages * feat/navigate restructure directory and add tests * feat/navigate test aliases validation * feat/navigate validate aliases before sending * feat/navigate create data endpoint * feat/navigate config: prettier * feat/navigate invalidate empty strings * feat/navigate create endpoints * feat/navigate parse on import * feat/navigate navigate to alias * feat/navigate user help and sample data * feat/navigate refact aliases modal * feat/navigate refact settings style * feat/navigate update sample db * feat/navigate link is relative to hostname * feat/navigate navigate to first match * feat/navigate update readme and version bump * feat/navigate config: create shared module * feat/navigate config: cheat module install * feat/navigate fix tests * feat/navigate run tests in pull request * Update ontime_cy.yml
29 lines
956 B
JavaScript
29 lines
956 B
JavaScript
/**
|
|
* Validates an alias against defined parameters
|
|
* @param {string} alias
|
|
* @returns {{message: string, status: boolean}}
|
|
*/
|
|
export const validateAlias = (alias) => {
|
|
|
|
const valid = { status: true, message: 'ok' };
|
|
|
|
if (alias === '' || alias == null) {
|
|
// cannot be empty
|
|
valid.status = false;
|
|
valid.message = 'should not be empty';
|
|
} else if (alias.includes('http') || alias.includes('https') || alias.includes('www')) {
|
|
// cannot contain http, https or www
|
|
valid.status = false;
|
|
valid.message = 'should not include http, https, www';
|
|
} else if (alias.includes('127.0.0.1') || alias.includes('localhost') || alias.includes('0.0.0.0')) {
|
|
// aliases cannot contain hostname
|
|
valid.status = false;
|
|
valid.message = 'should not include hostname';
|
|
} else if (alias.includes('editor')) {
|
|
// no editor
|
|
valid.status = false;
|
|
valid.message = 'No aliases to editor page allowed';
|
|
}
|
|
|
|
return valid;
|
|
}; |