Repository: iddm/urlshortener-rs (language: rust)

Issue:
Parsing issue with bit.ly when long url contains "#"
ex: Long Url: ```google.com/asd#123```
Output :
```{"status_code":200,"status_txt":"OK","data":{"url":"http://bit.ly/2nYsQDH","hash":"2nYsQDH","global_hash":"ipdYoe","long_url":"http://google.com/asd","new_hash":0}}```


Discussion / hints:
Looks like we or the service truncates the anchor from the url. I think this is the `urlshortener` crate itself because, I think, it does not properly encode the url to the percent encoding.

This can be fixed with something like this:

```rust
use url::percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
define_encode_set! {
    /// This encode set is used in the URL parser for query strings.
    pub QUERY_ENCODE_SET = [SIMPLE_ENCODE_SET] | {' ', '"', '#', '<', '>'}
}

fn main() {
    assert_eq!(utf8_percent_encode("http://google.com/asd#123", QUERY_ENCODE_SET).collect::<String>(), "http://google.com/asd%23123");
}
```
@arshubham Would you like to try fixing this? The solution seems to be quite simple.
Yeah, that would be great. Will make a pull by tomorrow.

Fix patch:
diff --git a/src/providers.rs b/src/providers.rs
index 9a95575f..f301420d 100644
--- a/src/providers.rs
+++ b/src/providers.rs
@@ -3,6 +3,7 @@
 use reqwest::{Client, Response};
 use reqwest::header::{ContentType, UserAgent};
 use url::form_urlencoded;
+use url::percent_encoding::{utf8_percent_encode, QUERY_ENCODE_SET};
 
 /// A user agent for faking weird serices.
 const FAKE_USER_AGENT: &str =
@@ -234,9 +235,10 @@ request!(
 
 parse!(bitly_parse);
 fn bitly_req(url: &str, key: &str, client: &Client) -> Option<Response> {
+    let encoded_url = utf8_percent_encode(url, QUERY_ENCODE_SET).collect::<String>();
     let address = format!(
         "https://api-ssl.bitly.com/v3/shorten?access_token={}&longUrl={}&format=txt",
-        key, url
+        key, encoded_url
     );
     client.get(&address).send().ok()
 }


Test patch: