mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Ensure unique selectors for loaded extension files
This commit is contained in:
@ -67,6 +67,16 @@ export function escapeHtml(str) {
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Make string safe for use as a CSS selector.
|
||||
* @param {string} str String to sanitize
|
||||
* @param {string} replacement Replacement for invalid characters
|
||||
* @returns {string} Sanitized string
|
||||
*/
|
||||
export function sanitizeSelector(str, replacement = '_') {
|
||||
return String(str).replace(/[^a-z0-9_-]/ig, replacement);
|
||||
}
|
||||
|
||||
export function isValidUrl(value) {
|
||||
try {
|
||||
new URL(value);
|
||||
|
Reference in New Issue
Block a user