Strings.prefix()
Syntax
function prefix(string: string, prefix: string): string
Adds a prefix to a string if it does not yet exist.
Parameters | |
string
|
The string to prefix. |
prefix
|
The prefix to add. If the string already starts with this prefix, this function does nothing. |
Example
import { Strings } from 'potence';
Strings.prefix('www.google.com', 'https://'); // -> 'https://www.google.com'
Strings.prefix('https://www.google.com', 'https://'); // -> 'https://www.google.com'
Remarks
Compare Strings.suffix()
.