urla
v0.0.4
Published
Easy url manipulation in the browser
Downloads
3
Readme
urla
Easy url manipulation in the browser.
Documentation
queryString(name: string, encoded?: boolean): string | boolean | undefined
Finds the value of parameter passed in first argument.
parseQuery(search: string): object
Parses a string as querystring. Like the queryString
method does, if the parameter is there, but it doesn't have a value, the value will be true
.
stringify(queryObj: object): string
Stringifies a query object.
updateSearchParam(param: string | object, value: string | undefined, push: boolean = true, triggerPopState: boolean = false): void
Adds, updates or deletes a parameter (without page refresh). If value
argument is undefined
, the parameter will be removed.
getLocation(): string
Returns the page url (without domain name).
hash(newHash: string, triggerPopState: boolean = false): string
Gets/sets the hash value.
_urlOverwrite(str: string, push: boolean = true, triggerPopState: boolean = false): string
Update the full url (pathname, search, hash).
getLocation(pathname: string, push: boolean = true, triggerPopState: boolean = false): string
Gets/sets the pathname.
triggerPopStateCb()
Calls the popstate handlers.
onPopState(cb: (...args: any[]) => void)
Adds a popstate handler.
removeHash(push: boolean = true, trigger: boolean = false)
Removes the hash from the url.
removeQuery(push: boolean = true, trigger: boolean = false)
Removes the querystring parameters from the url.