From f0cb4fafbe4f3f1ecb23b4dd9d7357a269c1317e Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 8 Aug 2018 10:31:14 +0800 Subject: Replace title in content --- src/content.rs | 2 +- src/main.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/content.rs b/src/content.rs index 0f81149..30d8f22 100644 --- a/src/content.rs +++ b/src/content.rs @@ -21,7 +21,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(&urlencoding::encode(title)); + url.push_str(&urlencoding::encode(&title.replace(" ", "_"))); url.push_str("&"); url.push_str("redirects=1&"); url.push_str("pllimit=100&"); diff --git a/src/main.rs b/src/main.rs index a5c10e1..982550f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -117,8 +117,7 @@ fn search(s: &mut Cursive) { fn on_submit(s: &mut Cursive, name: &str) { // get article data - let heading: String = name.to_string(); - let url = query_url_gen(&name.replace(" ", "_")); + let url = query_url_gen(name); let mut extract = String::new(); let mut link_vec: Vec = vec![]; @@ -153,6 +152,6 @@ fn on_submit(s: &mut Cursive, name: &str) { ).on_event('t', |s| match s.pop_layer() { _ => (), }), - ).title(heading), + ).title(name), ); } -- cgit v1.2.3