From 5b06a4ef9b8b2d9cc18f18c4ff6cfddf632f7483 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Mon, 16 Jul 2018 21:14:46 +0530 Subject: Fix url handling --- Cargo.toml | 1 + src/content.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c9adcf3..286bdaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ reqwest = { git = "https://github.com/seanmonstar/reqwest" } serde_json = { git = "https://github.com/serde-rs/json" } cursive = { git = "https://github.com/gyscos/Cursive" } regex = "1" +urlencoding = "1.0.0" diff --git a/src/content.rs b/src/content.rs index 13582f1..b72f4a8 100644 --- a/src/content.rs +++ b/src/content.rs @@ -2,6 +2,7 @@ extern crate reqwest; extern crate serde_json; extern crate cursive; extern crate regex; +extern crate urlencoding; use cursive::theme::Effect; use cursive::utils::markup::StyledString; @@ -19,7 +20,7 @@ pub fn query_url_gen(title: &str) -> String { url.push_str("prop=extracts%7Clinks&"); url.push_str("indexpageids=1&"); url.push_str("titles="); - url.push_str(title); + url.push_str(&urlencoding::encode(title)); url.push_str("&"); url.push_str("redirects=1&"); url.push_str("pllimit=40&"); @@ -35,7 +36,7 @@ pub fn search_url_gen(search: &str) -> String { url.push_str("action=opensearch&"); url.push_str("format=json&"); url.push_str("search="); - url.push_str(search); + url.push_str(&urlencoding::encode(search)); url.push_str("&"); url.push_str("limit=20"); url -- cgit v1.2.3