diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 50b804a..f439a0e 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -180,7 +180,7 @@ // initialize the root package if (!cmd.skipDubInitialization) { // initialize DUB - auto package_suppliers = registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))).array; + auto package_suppliers = registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))).array; dub = new Dub(package_suppliers, root_path); dub.dryRun = annotate; diff --git a/source/dub/dub.d b/source/dub/dub.d index f49a68c..52f5f9d 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -41,7 +41,7 @@ /// hosted by code.dlang.org. PackageSupplier[] defaultPackageSuppliers() { - Url url = Url.parse("http://code.dlang.org/"); + URL url = URL.parse("http://code.dlang.org/"); logDiagnostic("Using dub registry url '%s'", url); return [new RegistryPackageSupplier(url)]; } @@ -87,11 +87,11 @@ PackageSupplier[] ps = additional_package_suppliers; if (auto pp = "registryUrls" in m_userConfig) ps ~= deserializeJson!(string[])(*pp) - .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))) + .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))) .array; if (auto pp = "registryUrls" in m_systemConfig) ps ~= deserializeJson!(string[])(*pp) - .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))) + .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))) .array; ps ~= defaultPackageSuppliers(); diff --git a/source/dub/internal/utils.d b/source/dub/internal/utils.d index f6432bc..5d77ed0 100644 --- a/source/dub/internal/utils.d +++ b/source/dub/internal/utils.d @@ -121,7 +121,7 @@ } else assert(false); } /// ditto -void download(Url url, Path filename) +void download(URL url, Path filename) { download(url.toString(), filename.toNativeString()); } @@ -140,7 +140,7 @@ } else assert(false); } /// ditto -char[] download(Url url) +char[] download(URL url) { return download(url.toString()); } diff --git a/source/dub/internal/vibecompat/inet/path.d b/source/dub/internal/vibecompat/inet/path.d index 5152f68..7525a10 100644 --- a/source/dub/internal/vibecompat/inet/path.d +++ b/source/dub/internal/vibecompat/inet/path.d @@ -7,6 +7,9 @@ */ module dub.internal.vibecompat.inet.path; +version (Have_vibe_d) public import vibe.inet.path; +else: + import std.algorithm; import std.array; import std.conv; @@ -244,14 +247,13 @@ hash_t toHash() const nothrow @trusted { hash_t ret; - auto strtid = typeid(string); - try foreach (n; nodes) ret ^= strtid.getHash(&n.m_name); + auto strhash = &typeid(string).getHash; + try foreach (n; nodes) ret ^= strhash(&n.m_name); catch assert(false); if (m_absolute) ret ^= 0xfe3c1738; if (m_endsWithSlash) ret ^= 0x6aa4352d; return ret; } - } struct PathEntry { diff --git a/source/dub/internal/vibecompat/inet/url.d b/source/dub/internal/vibecompat/inet/url.d index de01cdc..45b16f2 100644 --- a/source/dub/internal/vibecompat/inet/url.d +++ b/source/dub/internal/vibecompat/inet/url.d @@ -9,6 +9,9 @@ public import dub.internal.vibecompat.inet.path; +version (Have_vibe_d) public import vibe.inet.url; +else: + import std.algorithm; import std.array; import std.conv; @@ -20,7 +23,7 @@ /** Represents a URL decomposed into its components. */ -struct Url { +struct URL { private { string m_schema; string m_pathString; @@ -107,9 +110,9 @@ this.localURI = str; } /// ditto - static Url parse(string url_string) + static URL parse(string url_string) { - return Url(url_string); + return URL(url_string); } /// The schema/protocol part of the URL @@ -194,8 +197,8 @@ } /// The URL to the parent path with query string and anchor stripped. - @property Url parentUrl() const { - Url ret; + @property URL parentURL() const { + URL ret; ret.schema = schema; ret.host = host; ret.port = port; @@ -229,29 +232,29 @@ return dst.data; } - bool startsWith(const Url rhs) const { + bool startsWith(const URL rhs) const { if( m_schema != rhs.m_schema ) return false; if( m_host != rhs.m_host ) return false; // FIXME: also consider user, port, querystring, anchor etc return path.startsWith(rhs.m_path); } - Url opBinary(string OP)(Path rhs) const if( OP == "~" ) { return Url(m_schema, m_host, m_port, m_path ~ rhs); } - Url opBinary(string OP)(PathEntry rhs) const if( OP == "~" ) { return Url(m_schema, m_host, m_port, m_path ~ rhs); } + URL opBinary(string OP)(Path rhs) const if( OP == "~" ) { return URL(m_schema, m_host, m_port, m_path ~ rhs); } + URL opBinary(string OP)(PathEntry rhs) const if( OP == "~" ) { return URL(m_schema, m_host, m_port, m_path ~ rhs); } void opOpAssign(string OP)(Path rhs) if( OP == "~" ) { m_path ~= rhs; } void opOpAssign(string OP)(PathEntry rhs) if( OP == "~" ) { m_path ~= rhs; } /// Tests two URLs for equality using '=='. - bool opEquals(ref const Url rhs) const { + bool opEquals(ref const URL rhs) const { if( m_schema != rhs.m_schema ) return false; if( m_host != rhs.m_host ) return false; if( m_path != rhs.m_path ) return false; return true; } /// ditto - bool opEquals(const Url other) const { return opEquals(other); } + bool opEquals(const URL other) const { return opEquals(other); } - int opCmp(ref const Url rhs) const { + int opCmp(ref const URL rhs) const { if( m_schema != rhs.m_schema ) return m_schema.cmp(rhs.m_schema); if( m_host != rhs.m_host ) return m_host.cmp(rhs.m_host); if( m_path != rhs.m_path ) return m_path.opCmp(rhs.m_path); @@ -260,12 +263,12 @@ } unittest { - auto url = Url.parse("https://www.example.net/index.html"); + auto url = URL.parse("https://www.example.net/index.html"); assert(url.schema == "https", url.schema); assert(url.host == "www.example.net", url.host); assert(url.path == Path("/index.html"), url.path.toString()); - url = Url.parse("http://jo.doe:password@sub.www.example.net:4711/sub2/index.html?query#anchor"); + url = URL.parse("http://jo.doe:password@sub.www.example.net:4711/sub2/index.html?query#anchor"); assert(url.schema == "http", url.schema); assert(url.username == "jo.doe", url.username); assert(url.password == "password", url.password); diff --git a/source/dub/packagesupplier.d b/source/dub/packagesupplier.d index 822ad20..f1c903b 100644 --- a/source/dub/packagesupplier.d +++ b/source/dub/packagesupplier.d @@ -97,11 +97,11 @@ /// Client PackageSupplier using the registry available via registerVpmRegistry class RegistryPackageSupplier : PackageSupplier { private { - Url m_registryUrl; + URL m_registryUrl; Json[string] m_allMetadata; } - this(Url registry) + this(URL registry) { m_registryUrl = registry; }