>From 53f70e0140b2eab531fbe320e50e27d2e598dd53 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 4 Nov 2010 23:36:54 +0000 Subject: [PATCH] Show the full URL in site chooser If, for example, I manually add the site http://mirrors.kernel.org/sources.redhat.com/cygwinports/ to setup's mirror list, currently I get two indistinguishable entries named http://mirrors.kernel.org. Furthermore, because the code to ensure the site just added is selected uses the string inside the list control to locate elements, we end up with a random one of those two indistinguishable entries selected (usually the previously existing one). This problem also prevents the selection of such indistingushable sites from being correctly saved and restored for the next setup run. So, to make the site chooser list entries unique and distinguishable, show the full URL 2010-11-09 Jon TURNEY * site.cc (init): Show full URL, not just protocol and sitename in the site chooser --- site.cc | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/site.cc b/site.cc index cafeac3..c496a12 100644 --- a/site.cc +++ b/site.cc @@ -140,10 +140,13 @@ site_list_type::init (const string &_url, const string &_servername, servername = _servername; area = _area; location = _location; - displayed_url = url.substr (0, url.find ("/", url.find ("."))); + displayed_url = _url; + /* the sorting key is hostname components in reverse order (to sort by country code) + plus the url (to ensure uniqueness) */ key = string(); - string::size_type last_idx = displayed_url.length () - 1; + string::size_type path_offset = url.find ("/", url.find ("//") + 2); + string::size_type last_idx = path_offset - 1; string::size_type idx = url.find_last_of("./", last_idx); if (last_idx - idx == 3) { -- 1.7.2.3