summaryrefslogtreecommitdiffabout
path: root/lib/util.cc
authorMichael Krelin <hacker@klever.net>2005-07-20 23:17:25 (UTC)
committer Michael Krelin <hacker@klever.net>2005-07-20 23:17:25 (UTC)
commit84a0285be7c7a57cfc00cb31a4a1da9902fa1b34 (patch) (unidiff)
tree608822c31cbedeb35c7341b88456dd9c826b4d27 /lib/util.cc
parent9634a1491130ef24130454e951672301e805351f (diff)
downloadlibopkele-84a0285be7c7a57cfc00cb31a4a1da9902fa1b34.zip
libopkele-84a0285be7c7a57cfc00cb31a4a1da9902fa1b34.tar.gz
libopkele-84a0285be7c7a57cfc00cb31a4a1da9902fa1b34.tar.bz2
moved util::canonicalize_url to consumer class
Diffstat (limited to 'lib/util.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/util.cc25
1 files changed, 0 insertions, 25 deletions
diff --git a/lib/util.cc b/lib/util.cc
index 1e7335c..d78b5e0 100644
--- a/lib/util.cc
+++ b/lib/util.cc
@@ -83,31 +83,6 @@ namespace opkele {
83 * 83 *
84 */ 84 */
85 85
86 string canonicalize_url(const string& url) {
87 string rv = url;
88 // strip leading and trailing spaces
89 string::size_type i = rv.find_first_not_of(" \t\r\n");
90 if(i==string::npos)
91 throw bad_input(OPKELE_CP_ "empty URL");
92 if(i)
93 rv.erase(0,i);
94 i = rv.find_last_not_of(" \t\r\n");
95 assert(i!=string::npos);
96 if(i<(rv.length()-1))
97 rv.erase(i+1);
98 // add missing http://
99 i = rv.find("://");
100 if(i==string::npos) { // primitive. but do we need more?
101 rv.insert(0,"http://");
102 i = sizeof("http://")-1;
103 }else{
104 i += sizeof("://")-1;
105 }
106 if(rv.find('/',i)==string::npos)
107 rv += '/';
108 return rv;
109 }
110
111 string url_encode(const string& str) { 86 string url_encode(const string& str) {
112 char * t = curl_escape(str.c_str(),str.length()); 87 char * t = curl_escape(str.c_str(),str.length());
113 if(!t) 88 if(!t)