This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH 2/4] Canonicalize mirror URLs to ensure they end with a '/'
- From: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- Date: Fri, 26 Nov 2010 13:48:38 +0000
- Subject: [PATCH 2/4] Canonicalize mirror URLs to ensure they end with a '/'
- References: <1290779320-872-1-git-send-email-jon.turney@dronecode.org.uk>
This prevents a mirror URL being added twice (with and without a terminal '/')
This ensures that the download directory is consistently named, avoiding
downloading everything again, even if an additional mirror URL is added
in a form which differs in the presence of a terminal '/' from last time.
2010-11-26 Jon TURNEY <jon.turney@dronecode.org.uk>
* site.cc (init): Canonicalize mirror URLs to ensure the end
with a '/'.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
site.cc | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/site.cc b/site.cc
index 42839f3..ff617b5 100644
--- a/site.cc
+++ b/site.cc
@@ -141,6 +141,10 @@ site_list_type::init (const string &_url, const string &_servername,
area = _area;
location = _location;
+ /* Canonicalize URL to ensure it ends with a '/' */
+ if (url.at(url.length()-1) != '/')
+ url.append("/");
+
/* displayed_url is protocol and site name part of url */
string::size_type path_offset = url.find ("/", url.find ("//") + 2);
displayed_url = url.substr(0, path_offset);
--
1.7.2.3