We have today released the first BETA version of our Javascript URL Library. This library is available for use under the GPL.
This Javascript library facilitates the easy construction and deconstruction of URL strings by breaking the URL into it’s various components.
This library is capable or taking a URL as a string or using the current window.location and parsing it into a URL object. Any of the components of the URL can then easily be manipulated as required and the modified URL string can be retrieved. The manipulation of query string arguments is facilitated by the addArg and removeArg methods.
The download for this library includes the Javascript code, a minified copy of the code, an HTML file containing examples and test cases and license information.
The project is available here.
A brief run down of the functions/methods available in this library:
FLQ.URL - Fliquid URL building/handling class.
thisURL() - Parses the current window.location and returns a FLQ.URL object.
set() - Parses a URL and sets the properties of the FLQ.URL object.
removeArg() - Is used remove a specified argument from the FLQ.URL object arguments.
addArg() - Is used to add an argument with specified value to the FLQ.URL object arguments.
parseURL() - Parses the specified URL and returns an object containing the various components.
parseArgs() - Parses a query string and returns an object containing the parsed data.
toArgs() - Takes an object and returns a query string
toAbsolute() - Returns a string containing the absolute URL for the current FLQ.URL object.
toRelative() - Returns a string containing the relative URL for the current FLQ.URL object.
isHost() - Is used to determine whether the host in the FLQ.URL object matches the current host.
toString() - Returns a string containing the current FLQ.URL object as a URL.
0 comments
Post a Comment