mirror of https://github.com/aria2/aria2
Use short form of util::startsWith and util::endsWith
parent
9331f6a43d
commit
b6fd4366fe
|
@ -253,8 +253,7 @@ AuthConfigFactory::findBasicCred
|
|||
std::lower_bound(basicCreds_.begin(), basicCreds_.end(), bc);
|
||||
for(; i != basicCreds_.end() && (*i).host_ == host && (*i).port_ == port;
|
||||
++i) {
|
||||
if(util::startsWith(bc.path_.begin(), bc.path_.end(),
|
||||
(*i).path_.begin(), (*i).path_.end())) {
|
||||
if(util::startsWith(bc.path_, (*i).path_)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ bool tailMatch
|
|||
(InputIterator first, InputIterator last, const std::string& target)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
if(util::endsWith(target.begin(), target.end(),
|
||||
(*first).begin(), (*first).end())) {
|
||||
if(util::endsWith(target, *first)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,13 +71,9 @@ bool DHTMessageTrackerEntry::match(const std::string& transactionID, const std::
|
|||
if(targetNode_->getIPAddress() == ipaddr) {
|
||||
return true;
|
||||
}
|
||||
if(util::endsWith(targetNode_->getIPAddress().begin(),
|
||||
targetNode_->getIPAddress().end(),
|
||||
ipaddr.begin(), ipaddr.end())) {
|
||||
if(util::endsWith(targetNode_->getIPAddress(), ipaddr)) {
|
||||
return targetNode_->getIPAddress() == "::ffff:"+ipaddr;
|
||||
} else if(util::endsWith(ipaddr.begin(), ipaddr.end(),
|
||||
targetNode_->getIPAddress().begin(),
|
||||
targetNode_->getIPAddress().end())) {
|
||||
} else if(util::endsWith(ipaddr, targetNode_->getIPAddress())) {
|
||||
return ipaddr == "::ffff:"+targetNode_->getIPAddress();
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -383,10 +383,7 @@ void DownloadCommand::installStreamFilter
|
|||
streamFilter->installDelegate(streamFilter_);
|
||||
streamFilter_ = streamFilter;
|
||||
const std::string& name = streamFilter_->getName();
|
||||
sinkFilterOnly_ =
|
||||
util::endsWith(name.begin(), name.end(),
|
||||
SinkStreamFilter::NAME.begin(),
|
||||
SinkStreamFilter::NAME.end());
|
||||
sinkFilterOnly_ = util::endsWith(name, SinkStreamFilter::NAME);
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -92,10 +92,7 @@ bool HttpDownloadCommand::prepareForNextSegment() {
|
|||
(getRequest()->isKeepAliveEnabled() &&
|
||||
(
|
||||
// Make sure that all filters are finished to pool socket
|
||||
(!util::endsWith(streamFilterName.begin(),
|
||||
streamFilterName.end(),
|
||||
SinkStreamFilter::NAME.begin(),
|
||||
SinkStreamFilter::NAME.end()) &&
|
||||
(!util::endsWith(streamFilterName, SinkStreamFilter::NAME) &&
|
||||
getStreamFilter()->finished()) ||
|
||||
getRequestEndOffset() ==
|
||||
getFileEntry()->gtoloff(getSegments().front()->getPositionToWrite())
|
||||
|
|
|
@ -248,8 +248,7 @@ std::string HttpRequest::createRequest()
|
|||
std::vector<std::string>::const_iterator j = headers_.begin();
|
||||
std::vector<std::string>::const_iterator jend = headers_.end();
|
||||
for(; j != jend; ++j) {
|
||||
if(util::startsWith((*j).begin(), (*j).end(),
|
||||
(*i).first.begin(), (*i).first.end())) {
|
||||
if(util::startsWith(*j, (*i).first)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,10 +95,7 @@ void HttpSkipResponseCommand::installStreamFilter
|
|||
streamFilter->installDelegate(streamFilter_);
|
||||
streamFilter_ = streamFilter;
|
||||
const std::string& name = streamFilter_->getName();
|
||||
sinkFilterOnly_ =
|
||||
util::endsWith(name.begin(), name.end(),
|
||||
SinkStreamFilter::NAME.begin(),
|
||||
SinkStreamFilter::NAME.end());
|
||||
sinkFilterOnly_ = util::endsWith(name, SinkStreamFilter::NAME);
|
||||
}
|
||||
|
||||
bool HttpSkipResponseCommand::executeInternal()
|
||||
|
|
|
@ -528,9 +528,9 @@ void HttpProxyOptionHandler::parseArg(Option& option, const std::string& optarg)
|
|||
option.put(pref_, optarg);
|
||||
} else {
|
||||
std::string uri;
|
||||
if(util::startsWith(optarg.begin(), optarg.end(), "http://") ||
|
||||
util::startsWith(optarg.begin(), optarg.end(), "https://") ||
|
||||
util::startsWith(optarg.begin(), optarg.end(), "ftp://")) {
|
||||
if(util::startsWith(optarg, "http://") ||
|
||||
util::startsWith(optarg, "https://") ||
|
||||
util::startsWith(optarg, "ftp://")) {
|
||||
uri = optarg;
|
||||
} else {
|
||||
uri = "http://";
|
||||
|
|
|
@ -373,8 +373,7 @@ std::string canonicalizeHost(const std::string& host)
|
|||
bool domainMatch(const std::string& requestHost, const std::string& domain)
|
||||
{
|
||||
return requestHost == domain ||
|
||||
(util::endsWith(requestHost.begin(), requestHost.end(),
|
||||
domain.begin(), domain.end()) &&
|
||||
(util::endsWith(requestHost, domain) &&
|
||||
requestHost[requestHost.size()-domain.size()-1] == '.' &&
|
||||
!util::isNumericHost(requestHost));
|
||||
}
|
||||
|
@ -382,8 +381,7 @@ bool domainMatch(const std::string& requestHost, const std::string& domain)
|
|||
bool pathMatch(const std::string& requestPath, const std::string& path)
|
||||
{
|
||||
return requestPath == path ||
|
||||
(util::startsWith(requestPath.begin(), requestPath.end(),
|
||||
path.begin(), path.end()) &&
|
||||
(util::startsWith(requestPath, path) &&
|
||||
(path[path.size()-1] == '/' || requestPath[path.size()] == '/'));
|
||||
}
|
||||
|
||||
|
|
|
@ -1616,6 +1616,11 @@ bool startsWith(const std::string& a, const char* b)
|
|||
return startsWith(a.begin(), a.end(), b, b+strlen(b));
|
||||
}
|
||||
|
||||
bool startsWith(const std::string& a, const std::string& b)
|
||||
{
|
||||
return startsWith(a.begin(), a.end(), b.begin(), b.end());
|
||||
}
|
||||
|
||||
bool istartsWith(const std::string& a, const char* b)
|
||||
{
|
||||
return istartsWith(a.begin(), a.end(), b, b+strlen(b));
|
||||
|
|
|
@ -624,6 +624,7 @@ bool startsWith(InputIterator first, InputIterator last, const char* b)
|
|||
}
|
||||
|
||||
bool startsWith(const std::string& a, const char* b);
|
||||
bool startsWith(const std::string& a, const std::string& b);
|
||||
|
||||
template<typename InputIterator1, typename InputIterator2>
|
||||
bool istartsWith
|
||||
|
|
Loading…
Reference in New Issue