Skip to content

Commit

Permalink
Usages update
Browse files Browse the repository at this point in the history
  • Loading branch information
indyarocks authored May 7, 2017
1 parent d84ec13 commit f9fdebe
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,32 @@ Or install it yourself as:
$ gem install final_redirect_url

## Usage
NOTE: The input url must start with http/https protocol.

```ruby
FinalRedirectUrl.final_redirect_url('http://www.google.com')
```

From IRB:
```ruby
2.4.0 :001 > require 'final_redirect_url'
=> true

# No protocol provided
2.4.0 :002 > FinalRedirectUrl.final_redirect_url('www.google.com')
=> ""

# With valid protocol
2.4.0 :003 > FinalRedirectUrl.final_redirect_url('http://google.com')
redirected to http://www.google.co.in/?gfe_rd=cr&ei=J-cOWYKhCKb98wfOsb2ADA
=> "http://www.google.co.in/?gfe_rd=cr&ei=J-cOWYKhCKb98wfOsb2ADA"

# URI with invalid response
2.4.0 :004 > FinalRedirectUrl.final_redirect_url('http://api.google.com')
E, [2017-05-07T14:52:39.497203 #1358] ERROR -- : bad URI(is not URI?):
=> ""
```

Usually the gem checks for redirect upto 10 depth level. However you can pass `{depth: 20}` to check redirects upto `20` depth.

## Contributing
Expand Down

0 comments on commit f9fdebe

Please sign in to comment.