mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 08:23:55 +00:00
45fe669f0a
* refactor: simplify excel import * chore: add external deepmerge utility * chore: create import map utilities * chore: increase size limits on uploads * style: small presentation tweaks * feat: resolve times on excel import, refs #508
21 lines
522 B
TypeScript
21 lines
522 B
TypeScript
/**
|
|
* @description Cleans given url
|
|
* @param {string} url - URL to be checked
|
|
* @returns {string} Sanitized url
|
|
*/
|
|
export const cleanURL = (url: string): string => {
|
|
// trim whitespaces
|
|
let sanitised = url.trim();
|
|
|
|
// clear any whitespaces
|
|
sanitised = sanitised.split(' ').join('%20');
|
|
|
|
// contain only allowed characters
|
|
sanitised = sanitised.replace(/([@\s<>[\]{}|\\^])+/g, '');
|
|
|
|
// starts with http://
|
|
if (!sanitised.startsWith('http://')) sanitised = `http://${sanitised}`;
|
|
|
|
return sanitised;
|
|
};
|