This function splits any well-formed URI into its parts (all are optional). All parts are split with a single regex using backreferences, and all groupings which don't contain complete URI parts are non-capturing.
- Created by: Steven Levithan
- Web Site: stevenlevithan.com
- Posted: October 24, 2008
- Comprehensively splits URIs, including splitting the query string into key/value pairs.
- Two parsing modes: loose and strict.
- Offers convenient, pre-concatenated components (path = directory and file; authority = userInfo, host, and port; etc.)
- Change the default names of URI parts without editing the function, by updating parseUri.options.key.
Paste this source code into the designated areas.
Paste this code into the
HEAD section of your HTML document.