[yast-commit] r40317 - in /trunk/pkg-bindings: package/yast2-pkg-bindings.changes src/Source.cc
Author: lslezak Date: Thu Aug 16 14:01:06 2007 New Revision: 40317 URL: http://svn.opensuse.org/viewcvs/yast?rev=40317&view=rev Log: - Pkg::SourceCreate() - use the last path component from URL as name (#299816) Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes trunk/pkg-bindings/src/Source.cc Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=40317&r1=40316&r2=40317&view=diff ============================================================================== --- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original) +++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Thu Aug 16 14:01:06 2007 @@ -2,6 +2,8 @@ Wed Aug 15 13:51:11 CEST 2007 - lslezak@suse.cz - return history of exceptions in Pkg::LastError() result (#299716) +- Pkg::SourceCreate() - use the last path component from URL as + name (#299816) ------------------------------------------------------------------- Thu Aug 9 10:20:08 CEST 2007 - lslezak@suse.cz Modified: trunk/pkg-bindings/src/Source.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source.cc?rev=40317&r1=40316&r2=40317&view=diff ============================================================================== --- trunk/pkg-bindings/src/Source.cc (original) +++ trunk/pkg-bindings/src/Source.cc Thu Aug 16 14:01:06 2007 @@ -1510,20 +1510,42 @@ // set alias and name if (alias.empty()) { - // alias not set via URL, use the passed alias or the URL + // alias not set via URL, use the passed alias or the URL path if (alias_r.empty()) { - // use URL + // use the last path element in URL std::string url_path = url.getPathName(); - // the URL is too long, extract only the most interesting parts - if (url_path.size() > 15) + std::string::size_type pos_begin = url_path.rfind("/"); + std::string::size_type pos_end = std::string::npos; + + // ignore the trailing slash + if (pos_begin == url_path.size() - 1) { - alias = shortenUrl(url).asString(); + pos_begin = url_path.rfind("/", url_path.size() - 2); + + if (pos_begin != std::string::npos) + { + pos_end = url_path.size() - pos_begin - 2; + } } else { - alias = url.asString(); + pos_end = url_path.size() - pos_begin - 1; + } + + // ignore the found slash character + pos_begin++; + + alias = std::string(url_path, pos_begin, pos_end); + + y2milestone("Alias from URL path: %s", alias.c_str()); + + // fallback + if (alias.empty()) + { + y2milestone("URL alias is empty using 'Repository'"); + alias = "Repository"; } } else -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org