Str
Contains static string utility methods.
Static Method Summary
Static Public Methods | ||
public static |
Checks whether a given string ends with a given other string |
|
public static |
forceLeadingSlash(str: string): string Ensures that a string starts with a slash |
|
public static |
forceTrailingSlash(str: string): string Ensures that a string ends with a slash |
|
public static |
Joins all given arguments to a string with slashes. |
|
public static |
Ensures that the first character of a string is in lowercase. |
|
public static |
Ensures that a string has a specified length. |
|
public static |
normalizePath(str: string): string Ensures that a given string starts with a slash and does not have a leading slash |
|
public static |
removeLeadingSlash(str: string): string Ensures that a string does not start with a slash |
|
public static |
removeTrailingSlash(str: string): string Ensures that a string does not end with a slash |
|
public static |
startsWith(str1: string, str2: string): boolean Checks whether a given string starts with a given other string |
|
public static |
Ensures that the first character of a string is in uppercase. |
Static Public Methods
public static endsWith(str1: string, str2: string): boolean source
Checks whether a given string ends with a given other string
public static forceLeadingSlash(str: string): string source
Ensures that a string starts with a slash
Params:
Name | Type | Attribute | Description |
str | string | The string in question |
public static forceTrailingSlash(str: string): string source
Ensures that a string ends with a slash
Params:
Name | Type | Attribute | Description |
str | string | The string in question |
public static joinPath(parts: ...string): string source
Joins all given arguments to a string with slashes. Ensures there are no duplicate slashes (e.g. in case one of the arguments already had a slash at its start or end)
Params:
Name | Type | Attribute | Description |
parts | ...string | Any number of strings |
public static lcFirst(str: string): string source
Ensures that the first character of a string is in lowercase.
Params:
Name | Type | Attribute | Description |
str | string | The string in question |
public static leftPad(value: string, length: number, fill: string): string source
Ensures that a string has a specified length.
Fills up missing length by inserting a fill
chartacter before the original value.
public static normalizePath(str: string): string source
Ensures that a given string starts with a slash and does not have a leading slash
Params:
Name | Type | Attribute | Description |
str | string | The string in question |
Return:
string | A string that starts with a slash and ends without a slasg (e.g. a valid location pathname) |
public static removeLeadingSlash(str: string): string source
Ensures that a string does not start with a slash
Params:
Name | Type | Attribute | Description |
str | string | The string in question |
public static removeTrailingSlash(str: string): string source
Ensures that a string does not end with a slash
Params:
Name | Type | Attribute | Description |
str | string | The string in question |