Delete a query (and its value) in a URL
If a query appears multiple times (which is a bit odd), all instances are removed
the URL to act on
the modified URL
May be either an absolute or a relative URL.
The URL the absolute URL should be relative to. This is usually the URL of the current page.
Get a suitable default filename for a given URL
If the URL:
the filename according to the above rules
Very incomplete lookup of extension for common mime types that might be encountered when saving elements on a page. There are NPM libs for this, but this should cover 99% of basic cases
mime type to get extension for (eg 'image/png')
an extension for that mimetype, or undefined if that type is not supported
Get the parent of the current URL. Parent is determined as:
the URL to get the parent of
removal option. Boolean properties: trailingSlash, ignoreFragment and ignoreSearch. Regular Expression properties: ignorePathRegExp. All properties are optional.
how many "generations" you wish to go back (1 = parent, 2 = grandparent, etc.)
the parent of the URL, or null if there is no parent
Get an Array of the queries in a URL.
These could be like "query" or "query=val"
Get the root of a URL
the url to find the root of
the root of the URL, or the original URL when the URL isn't suitable for finding the root of.
Graft a new path onto some parent of the current URL
E.g. grafting "by-name/foobar" onto the 2nd parent path: example.com/items/by-id/42 -> example.com/items/by-name/foobar
the URL to modify
the new "grafted" URL path tail
the graft point in terms of path levels >= 0: start at / and count right <0: start at the current path and count left
Increment the last number in a URL.
(perhaps this could be made so you can select the "nth" number in a URL rather than just the last one?)
the URL to increment
increment step to advance by (can be negative)
the incremented URL, or null if cannot be incremented
Interpolates a query or other search item into a URL
If the URL pattern contains "%s", the query is interpolated there. If not, it is appended to the end of the pattern.
If the interpolation point is in the query string of the URL, it is percent encoded, otherwise it is is inserted verbatim.
a URL to interpolate/append a query to
a query to interpolate/append into the URL
the URL with the query encoded (if needed) and inserted at the relevant point
Replace the value of a query in a URL with a new one
the URL to act on
the query key to replace the value for
the new value to use
Sets the value of a query in a URL with a specific one
the URL to act on
the query key to set the value for
the value to use
Update a URL with a new array of queries
URL handling utlity functions