-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_dot.cpp
More file actions
33 lines (28 loc) · 741 Bytes
/
remove_dot.cpp
File metadata and controls
33 lines (28 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <Poco/URI.h>
#include <iostream>
using namespace std;
#include "remove_dot.h"
string remove_dot(string uri){
//string uri = "http://ynet.co.il.//articles//0,7340,L-4715257,00.html.";
//cout << uri[uri.length()-1] << endl;
string host="";
string path="";
if( ! uri.empty()){
int last_char_uri=uri.length()-1;
if( uri[last_char_uri]=='.' || uri[last_char_uri]=='%' ){
uri.erase(last_char_uri,1);
}
Poco::URI uri1("http://"+uri);
uri1.normalize();
host=uri1.getAuthority();
path=uri1.getPathAndQuery();
int last_char_host=host.length()-1;
if(!host.empty() && host[last_char_host]=='.'){
host.erase(last_char_host,1);
}
}
//cout << host << endl;
//cout << path << endl;
//uri1.~URI();
return host+path;
}