mirror of https://github.com/aria2/aria2
2007-10-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Request.cc (parseUrl): Removed unnecessary slashes around dir.pull/1/head
parent
e5454000a6
commit
c0b467273c
|
@ -1,3 +1,7 @@
|
||||||
|
2007-10-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
* src/Request.cc (parseUrl): Removed unnecessary slashes around dir.
|
||||||
|
|
||||||
2007-10-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-10-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
* src/MultiUrlRequestInfo.h: Updated the message shown when program
|
* src/MultiUrlRequestInfo.h: Updated the message shown when program
|
||||||
|
|
|
@ -77,7 +77,6 @@ bool Request::parseUrl(const string& url) {
|
||||||
} else {
|
} else {
|
||||||
tempUrl = url;
|
tempUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentUrl = tempUrl;
|
currentUrl = tempUrl;
|
||||||
string query;
|
string query;
|
||||||
host = "";
|
host = "";
|
||||||
|
@ -122,7 +121,16 @@ bool Request::parseUrl(const string& url) {
|
||||||
dir = "/";
|
dir = "/";
|
||||||
direp = hep;
|
direp = hep;
|
||||||
} else {
|
} else {
|
||||||
dir = tempUrl.substr(hep, direp-hep);
|
string rawDir = tempUrl.substr(hep, direp-hep);
|
||||||
|
string::size_type p = rawDir.find_first_not_of("/");
|
||||||
|
if(p != string::npos) {
|
||||||
|
rawDir.erase(0, p-1);
|
||||||
|
}
|
||||||
|
p = rawDir.find_last_not_of("/");
|
||||||
|
if(p != string::npos) {
|
||||||
|
rawDir.erase(p+1);
|
||||||
|
}
|
||||||
|
dir = rawDir;
|
||||||
}
|
}
|
||||||
if(tempUrl.size() > direp+1) {
|
if(tempUrl.size() > direp+1) {
|
||||||
file = tempUrl.substr(direp+1);
|
file = tempUrl.substr(direp+1);
|
||||||
|
|
|
@ -21,6 +21,8 @@ class RequestTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testSetUrl12);
|
CPPUNIT_TEST(testSetUrl12);
|
||||||
CPPUNIT_TEST(testSetUrl13);
|
CPPUNIT_TEST(testSetUrl13);
|
||||||
CPPUNIT_TEST(testSetUrl14);
|
CPPUNIT_TEST(testSetUrl14);
|
||||||
|
CPPUNIT_TEST(testSetUrl15);
|
||||||
|
CPPUNIT_TEST(testSetUrl16);
|
||||||
CPPUNIT_TEST(testRedirectUrl);
|
CPPUNIT_TEST(testRedirectUrl);
|
||||||
CPPUNIT_TEST(testRedirectUrl2);
|
CPPUNIT_TEST(testRedirectUrl2);
|
||||||
CPPUNIT_TEST(testResetUrl);
|
CPPUNIT_TEST(testResetUrl);
|
||||||
|
@ -48,6 +50,8 @@ public:
|
||||||
void testSetUrl12();
|
void testSetUrl12();
|
||||||
void testSetUrl13();
|
void testSetUrl13();
|
||||||
void testSetUrl14();
|
void testSetUrl14();
|
||||||
|
void testSetUrl15();
|
||||||
|
void testSetUrl16();
|
||||||
void testRedirectUrl();
|
void testRedirectUrl();
|
||||||
void testRedirectUrl2();
|
void testRedirectUrl2();
|
||||||
void testResetUrl();
|
void testResetUrl();
|
||||||
|
@ -217,6 +221,30 @@ void RequestTest::testSetUrl14() {
|
||||||
CPPUNIT_ASSERT_EQUAL(string("abc?query"), req.getFile());
|
CPPUNIT_ASSERT_EQUAL(string("abc?query"), req.getFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RequestTest::testSetUrl15()
|
||||||
|
{
|
||||||
|
Request req;
|
||||||
|
// 2 slashes after host name and dir
|
||||||
|
bool v = req.setUrl("http://host//dir1/dir2//file");
|
||||||
|
CPPUNIT_ASSERT(v);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("host"), req.getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("/dir1/dir2"), req.getDir());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("file"), req.getFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RequestTest::testSetUrl16()
|
||||||
|
{
|
||||||
|
Request req;
|
||||||
|
// 2 slashes before file
|
||||||
|
bool v = req.setUrl("http://host//file");
|
||||||
|
CPPUNIT_ASSERT(v);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("host"), req.getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("/"), req.getDir());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("file"), req.getFile());
|
||||||
|
}
|
||||||
|
|
||||||
void RequestTest::testRedirectUrl() {
|
void RequestTest::testRedirectUrl() {
|
||||||
Request req;
|
Request req;
|
||||||
bool v = req.setUrl("http://aria.rednoah.com:8080/aria2/index.html");
|
bool v = req.setUrl("http://aria.rednoah.com:8080/aria2/index.html");
|
||||||
|
|
Loading…
Reference in New Issue