Files
SnowEyes/content/validators/api.validator.js
T
2024-12-27 18:33:02 +08:00

19 lines
441 B
JavaScript

const apiValidator = (function() {
return {
isNotFullUrl(path) {
return !/^(?:https?:)?\/\/[^\/]+/.test(path);
},
isNotStaticResource(path) {
return !API_CONFIG.STATIC_PATTERNS.some(pattern => pattern.test(path));
},
isValidPath(path) {
return path.length >= 3 &&
path.length <= 300 &&
/^\/[\w\-\.\/\@]+/.test(path);
}
};
})();
window.apiValidator = apiValidator;