fix: Improve performance of base64 detection regex
This commit is contained in:
@@ -86,6 +86,17 @@ export function isExternalUrl(url: string) {
|
||||
return !!url && !isInternalUrl(url) && !url.startsWith(creatingUrlPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns match if the given string is a base64 encoded url.
|
||||
*
|
||||
* @param url The url to check.
|
||||
* @returns A RegExp match if the url is base64, false otherwise.
|
||||
*/
|
||||
export function isBase64Url(url: string) {
|
||||
const match = url.match(/^(data:[a-z]+\/[^;]+;base64,(.*))/i);
|
||||
return match ? match : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* For use in the editor, this function will ensure that a url is
|
||||
* potentially valid, and filter out unsupported and malicious protocols.
|
||||
|
||||
Reference in New Issue
Block a user