Sanitizes a string by removing script tags and returning a safe string to be outputted on a page.
Parameters:
Name | Type | Description |
---|---|---|
unsafe | string | The string to be escaped/sanitized. |
- Since
- 1.0.0
- Source
Returns:
Returns a string with all script tags removed.
- Type:
- string
Example
import { escapeScripts } from "@gravityforms/utils";
function Example() {
const unsafeString = 'Some text <script>alert( "I am unsafe" );</script> that is not safe';
const safeString = escapeScripts( unsafeString );
}