The library for working with URLs.
- jQuery >= 3.5 (not tested with older versions)
<!-- Required libs -->
<script src="jQuery-3.5.0.min.js"></script>
<!-- jQuery.ddUrl -->
<script src="jQuery.ddUrl-2.1.1.min.js"></script>
console.log($.ddUrl.current);
-
jQuery.ddUrl.current
- Desctription: Always contains actual data about current page URL.
- Valid values:
objectPlain
-
jQuery.ddUrl.current.full
- Desctription: Full URL.
- Valid values:
string
-
jQuery.ddUrl.current.protocol
- Desctription: Protocol.
E. g.'http'
,'https'
. - Valid values:
string
- Desctription: Protocol.
-
jQuery.ddUrl.current.host
- Desctription: Domain name.
E. g.'example.com'
,'subdomain.example.com'
. - Valid values:
string
- Desctription: Domain name.
-
jQuery.ddUrl.current.port
- Desctription: Port.
- Valid values:
string
''
-
jQuery.ddUrl.current.origin
- Desctription: Origin (protocol, host and port together).
E. g.'https://example.com:443'
. - Valid values:
string
- Desctription: Origin (protocol, host and port together).
-
jQuery.ddUrl.current.relative
- Desctription: Relative path (all except origin).
- Valid values:
string
''
-
jQuery.ddUrl.current.path
- Desctription: Path only (all except origin, query and hash).
- Valid values:
string
''
-
jQuery.ddUrl.current.queryString
- Desctription: Query parameters as string.
E. g.'param1=value1¶m2=value2'
. - Valid values:
string
''
- Desctription: Query parameters as string.
-
jQuery.ddUrl.current.queryObject
- Desctription: Query parameters as object.
E. g.{param1: 'value1', param2: 'value2'}
. - Valid values:
objectPlain
{}
- Desctription: Query parameters as object.
-
jQuery.ddUrl.current.queryObject[$paramName]
- Desctription: Parameter, when key is parameter name, value is parameter value.
- Valid values:
mixed
-
jQuery.ddUrl.current.hashString
- Desctription: Hash as string.
E. g.'param1=value1¶m2=value2'
. - Valid values:
string
''
- Desctription: Hash as string.
-
jQuery.ddUrl.current.hashObject
- Desctription: Hash parameters as object if hash is set as query string.
E. g.{param1: 'value1', param2: 'value2'}
). - Valid values:
objectPlain
{}
- Desctription: Hash parameters as object if hash is set as query string.
-
jQuery.ddUrl.current.hashObject[$paramName]
- Desctription: Parameter, when key is parameter name, value is parameter value.
- Valid values:
mixed
-
jQuery.ddUrl.current.hashPath
- Desctription: Hash path as array (if URL is set as something like
'https://example.com#/some/path'
). - Valid values:
array
[]
- Desctription: Hash path as array (if URL is set as something like
-
jQuery.ddUrl.current.hashPath[i]
- Desctription: Path item.
- Valid values:
string
-
jQuery.ddUrl.current.isInternal
- Desctription: Does the URL refer to the current domain (always equal to
true
in thejQuery.ddUrl.current
object)? - Valid values:
boolean
- Desctription: Does the URL refer to the current domain (always equal to
Parse an URL string to an object.
url
- Desctription: URL to parse.
E. g.https://example.com/page?param1=value1/#filter[availiable]=1
. - Valid values:
string
- Default value:
window.location.toString()
(current page URL)
- Desctription: URL to parse.
result
- Desctription: Returns an object with the same fields as
jQuery.ddUrl.current
. - Valid values:
objectPlain
- Desctription: Returns an object with the same fields as
Parse a Query string to an object.
query
- Desctription: Query string to parse.
E. g.param1=value1¶m2=value2
. - Valid values:
string
- Required
- Desctription: Query string to parse.
result
- Valid values:
objectPlain
- Valid values:
Parse a path string to an array. All items will be trimmed, empty items will be removed.
path
- Desctription: Path string to parse.
- Valid values:
string
- Required
-
result
- Valid values:
array
- Valid values:
-
result[i]
- Valid values:
string
- Valid values: