GuobaGuoba Utils

ensureSuffix

@guoba-ai/utils / string / ensureSuffix

Function: ensureSuffix()

function ensureSuffix(str, suffix): string;

Defined in: string.ts:43

Ensure a string ends with a given suffix.

Parameters

str

string

The input string

suffix

string

The suffix to ensure

Returns

string

The string with the suffix appended if it was missing

Example

ensureSuffix('file.ts', '.ts') // 'file.ts'
ensureSuffix('file', '.ts') // 'file.ts'

On this page