Created
December 10, 2010 21:34
-
-
Save ericf/736865 to your computer and use it in GitHub Desktop.
Possible APIs for URL.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| URL('exmaple.com').toString() // http://example.com/ | |
| // Accessor methods | |
| URL('example.com').protocol(); // http: | |
| URL('foo.example.com').host(); // foo.example.com | |
| URL('foo.example.com').domain(); // example.com | |
| URL('example.com').path(); // / | |
| // or getter style | |
| URL('example.com').getProtocol(); // http: | |
| URL('foo.example.com').getHost(); // foo.example.com | |
| URL('foo.example.com').getDomain(); // example.com | |
| URL('example.com').getPath(); // / | |
| -------------------------- | |
| // Future! mutator methods | |
| URL('example.com').protocol('https:'); | |
| URL('foo.example.com').host('bar.example.com'); | |
| URL('example.com').path('/bar/'); | |
| // or setter style | |
| URL('example.com').setProtocol('https:'); | |
| URL('foo.example.com').setHost('bar.example.com'); | |
| URL('example.com').setPath('/bar/'); | |
| // Future! setter method chaining | |
| URL('example.com').protocol('https:').path('/bar/').toString(); // https://example.com/bar/ | |
| // or setter style | |
| URL('example.com').setProtocol('https:').setPath('/bar/').toString(); // https://example.com/bar/ | |
| -------------------------- | |
| // Constructors/Factories | |
| URL('http://example.com/'); | |
| // Future! Constructors/Factories | |
| URL().protocol('http:').host('example.com'); | |
| -------------------------- | |
| // Sanitizing features | |
| URL('Example.com?foo=').toString(); // http://example.com/?foo | |
| URL('example.com.').isValid(); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment