Home Reference Source
public class | source

Str

Contains static string utility methods.

Static Method Summary

Static Public Methods
public static

endsWith(str1: string, str2: string): boolean

Checks whether a given string ends with a given other string

public static

Ensures that a string starts with a slash

public static

Ensures that a string ends with a slash

public static

joinPath(parts: ...string): string

Joins all given arguments to a string with slashes.

public static

Ensures that the first character of a string is in lowercase.

public static

leftPad(value: string, length: number, fill: string): string

Ensures that a string has a specified length.

public static

Ensures that a given string starts with a slash and does not have a leading slash

public static

Ensures that a string does not start with a slash

public static

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

Params:

NameTypeAttributeDescription
str1 string

The string in question

str2 string

The string that is possibly contained at the end of str1

Return:

boolean

true if str1 ends with str2

public static forceLeadingSlash(str: string): string source

Ensures that a string starts with a slash

Params:

NameTypeAttributeDescription
str string

The string in question

Return:

string

A string that starts with a slash

public static forceTrailingSlash(str: string): string source

Ensures that a string ends with a slash

Params:

NameTypeAttributeDescription
str string

The string in question

Return:

string

A string that ends with a slash

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:

NameTypeAttributeDescription
parts ...string

Any number of strings

Return:

string

A string that contains all given strings, concatenated with slashes

public static lcFirst(str: string): string source

Ensures that the first character of a string is in lowercase.

Params:

NameTypeAttributeDescription
str string

The string in question

Return:

string

A string that starts with a lowercase letter

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.

Params:

NameTypeAttributeDescription
value string

The string in question

length number
  • optional
  • default: 2

The desired length for value

fill string
  • optional
  • default: "0"

The character to insert until length has been reached

Return:

string

A string that ends in value and has length chars

public static normalizePath(str: string): string source

Ensures that a given string starts with a slash and does not have a leading slash

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
str string

The string in question

Return:

string

A string that does not start with a slash

public static removeTrailingSlash(str: string): string source

Ensures that a string does not end with a slash

Params:

NameTypeAttributeDescription
str string

The string in question

Return:

string

A string that does not end with a slash

public static startsWith(str1: string, str2: string): boolean source

Checks whether a given string starts with a given other string

Params:

NameTypeAttributeDescription
str1 string

The string in question

str2 string

The string that is possibly contained at the beginning of str1

Return:

boolean

true if str1 starts with str2

public static ucFirst(str: string): string source

Ensures that the first character of a string is in uppercase.

Params:

NameTypeAttributeDescription
str string

The string in question

Return:

string

A string that starts with a uppercase letter