Show:

String Class

Q extended methods for Strings

Methods

decodeHTML

(
  • [convert]
)
String

Reverses what encodeHTML does

Parameters:

  • [convert] Array optional

    Array of codes to unconvert. Can include '&', '<', '>, '"', ''', "
    ", "
    "

Returns:

encodeHTML

(
  • [convert]
)
String

Returns a copy of the string with special HTML characters escaped

Parameters:

  • [convert] Array optional

    Array of characters to convert. Can include '&', '<', '>', '"', "'", "\n"

Returns:

hashCode

() Number

Obtain some unique hash from a string, analogous to Q_Utils::hashCode

Returns:

interpolate

(
  • fields
)
String

Interpolates some fields into the string wherever "{{fieldName}}" appears or {{index}} appears.

Parameters:

  • fields Object | Array

    Can be an object with field names and values, or an array corresponding to {{0}}, {{1}}, etc. If the string is missing {{0}} then {{1}} is mapped to the first element of the array.

Returns:

isUrl

() Boolean

Determins whether the string's contents are an IP address

Returns:

isUrl

() Boolean

Determins whether the string's contents are a URL

Returns:

parseUrl

(
  • component
)
Object

Analogous to PHP's parse_url function

Parameters:

  • component String

    Optional name of component to return

Returns:

queryField

(
  • name
  • [value]
)
String | Object

Get or set querystring fields from a string, usually from location.search or location.hash

Parameters:

  • name String | Array | Object

    The name of the field. If it's an array, returns an object of {name: value} pairs. If it's an object, then they are added onto the querystring and the result is returned. If it's a string, it's the name of the field to get. And if it's an empty string, then we get the array of field names with no value, e.g. ?123&456&a=b returns [123,456]

  • [value] String optional

    Optional, provide a value to set in the querystring, or null to delete any fields that match name as a RegExp

Returns:

String | Object:

the value of the field in the string, or if value was not undefined, the resulting querystring. Finally, if

replaceAll

() String

Similar to String.prototype.replace, but replaces globally

Returns:

sameDomain

(
  • url2
  • options
)
Boolean private

Parameters:

  • url2 String

    The url to compare against

  • options Object

    can include the following:

    • [compareScheme] Boolean optional

      boolean for whether the url scheme should be compared also

Returns:

startsWith

(
  • prefix
)
Boolean

Parameters:

Returns:

toCapitalized

() String

Returns a copy of the string with Every Word Capitalized

Returns:

trim

() String

Returns: