# Class: UrlParser

## UrlParser

#### new UrlParser(url)

  Parse an URL

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `url` | String |

  ##### Returns:

  the parsed url
  Type
    urlParser_Object

  ##### Example

      let url = new UrlParser( 'https://username:password@demo.domain.com:1337/section/page.html?param=1&param=2#anchor' );

      // Update the anchor and regenerate url
      url.setAnchor( 'anchor' )

      // Get a query param
      url.getParam( 'key' )

      // Get all query params
      url.getParam()
      // or
      this.queryKey

      // Add/modify a query param
      url.setParam( 'key', value )

      // Add/modify several query param
      url.setParam( {
       "key1": "value1",
       "key2": "value2"
      } )

      // Remove a query param
      url.removeParam( 'key' )
      url.removeParam( [ 'key1', 'key2', ... ] )

      // Remove all query param
      url.removeAll()

### Methods

#### getParam( [key])

  Get the value of a query param

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `key` | String | <optional> |

  ##### Returns:

  Type
    String | Object

#### removeAll()

  Delete all query param

  ##### Returns:

  Type
    UrlParser

#### removeParam(keys)

  Remove one or several query param

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `keys` | String | Array.<String> |

  ##### Returns:

  Type
    UrlParser

#### setAnchor(anchor)

  Change anchor and recreate all values

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `anchor` | String |

  ##### Returns:

  Type
    UrlParser

#### setParam(keys, value)

  Add/modify one or several query param

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `keys` | String | Object |
  `value` | String |

  ##### Returns:

  Type
    UrlParser

### Type Definitions

#### urlParser_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `absolute` | String | https://demo.domain.com:1337/section/page.html?param=2
  `absolute2` | String | https://demo.domain.com:1337/section/page.html?param=2#anchor
  `anchor` | String | anchor
  `authority` | String | username:password@demo.domain.com:1337
  `directory` | String | /section/
  `file` | String | page.html
  `full` | String | https://username:password@demo.domain.com:1337/section/page.html?param=2
  `full2` | String | https://username:password@demo.domain.com:1337/section/page.html?param=2#anchor
  `host` | String | demo.domain.com
  `location` | String | new UrlParser(window.location)
  `password` | String | password
  `path` | String | /section/page.html
  `port` | String | 1337
  `protocol` | String | https
  `query` | String | param=2
  `queryKey` | Object | { param: "2" }
  `relative` | String | Url without host, credential and anchor
  `relative2` | String | Url without host, credential but with anchor
  `source` | String | Original Url, never change: https://username:password@demo.domain.com:1337/section/page.html?param=1&param=2#anchor
  `user` | String | username
  `userInfo` | String | username:password
  `isAnchor` | Boolean | false
  `isSameDomain` | Boolean | false
  `setAnchor` | function |
  `setParam` | function |
  `removeParam` | function |
  `removeAll` | function |

#### Search results