Skip to content

Commit 5a0c87f

Browse files
committed
complete the readme file
1 parent ef68038 commit 5a0c87f

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
1-
# angular-url-parser
1+
# Angular URL parser
22
Get simple methods to manipulate url parts
3+
4+
> Demo: http://yllieth.github.io/angular-url-parser/app/index.html
5+
6+
## Installation
7+
8+
### Bower
9+
10+
```
11+
bower install angular-url-parser --save
12+
```
13+
14+
Once the lib is downloaded,
15+
16+
1. add a reference in your index.html
17+
18+
`<script type="application/javascript" src="../bower_components/angular-url-parser/angular-url-parser.js"></script>`
19+
20+
2. add the module in your angular application
21+
22+
```javascript
23+
angular
24+
.module('YOUR-ANGULAR-APP-NAME', [
25+
'angular-url-parser'
26+
])
27+
.controller('demoCtrl', function(urlParser) {
28+
this.protocol = urlParser.getProtocol();
29+
this.host = urlParser.getHost();
30+
this.hostname = urlParser.getHostname();
31+
this.port = urlParser.getPort();
32+
this.route = urlParser.getRoute();
33+
this.routeAttributes = urlParser.getRouteAttributes();
34+
this.queryString = urlParser.getQuerystring();
35+
this.option = urlParser.getOption();
36+
this.hash = urlParser.getHash();
37+
})
38+
```
39+
40+
3. enjoy!
41+
42+
## Usage
43+
44+
- `getProtocol([string] url): string` : Return the protocol of the given url - Example: _"http:"_, _"https:"_, ...
45+
- `getHost([string] url): string` : Return the host of the given url (without port) - Example: _"github.com"_, _"localhost"_, ...
46+
- `getHostname([string] url): string` : Return the hostname of the given url (with port) - Example: _"github.com"_, _"localhost:3000"_, ...
47+
- `getPort([string] url): string` : Return the port of the given url - Example: _""_, _"3000"_, ...
48+
- `getRoute([string] url): string` : Return the main parts of the given url
49+
- `getRouteAttributes([string] url): array` : Return the list of parts of the given url
50+
- `getQuerystring([string] url): string` : Return the part of the given url with options
51+
- `getOption([string] param, [string] url): object|string` : Return a specific option in the url's options, or all options in an object
52+
- `getHash([string] url): string` : Return the hash of the given url
53+
54+
# Contributing
55+
56+
1. Fork it
57+
2. Create your feature branch (`git checkout -b my-new-feature`)
58+
3. Commit your changes (`git commit -am 'Add some feature'`)
59+
4. Push to the branch (`git push origin my-new-feature`)
60+
5. Create new Pull Request

0 commit comments

Comments
 (0)