FIND YOUR NEXT FEW LINES

Results for “safe”

Small, practical examples. Search by task or narrow things down below.

34 snippets foundClear filters
Bash ScriptsText parsing & arithmetic

Print text containing percent characters literally

Bash Scripts: Never use untrusted text as the printf format string.

Bash Scripts✓ Tested
ReactAccessibility & events

Render untrusted-looking input as literal text

Render untrusted-looking input as literal text with a small React component and explicit browser behavior.

React✓ Tested
jQueryDOM & classes

Append a list item

Build a jQuery element with text and append it safely.

jQuery✓ Tested
PythonFiles & paths

Create nested folders

Create a folder and any missing parent folders in one call. Running the code again is safe when the folder already exists.

directory✓ Tested
Bash ScriptsFunctions & arguments

Give a function an optional argument

Let callers omit a value while keeping nounset enabled.

optional argument✓ Tested
TypeScriptSafe data handling

Handle a result with a discriminated union

Separate success data from an error message.

discriminated union✓ Tested
TypeScriptSafe data handling

Read a nested optional value

Avoid dereferencing a missing nested object.

optional chaining✓ Tested
TypeScriptSafe data handling

Update an object with a readonly input

Create a changed copy while retaining the original.

readonly✓ Tested
TypeScriptSafe data handling

Validate an unknown value with a type guard

Check a field before treating unknown data as a typed object.

unknown✓ Tested
HTMLInput constraints

Validate the shape of an absolute URL

HTML: A URL input checks syntax, not whether a resource exists or is safe.

HTML✓ Tested