From 0df194d33ea0b47877664409545c5422c433bd76 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 7 Jul 2016 15:53:01 +0100 Subject: [PATCH] Added method URL::withNewDomainAndPath() --- modules/juce_core/network/juce_URL.cpp | 7 +++++++ modules/juce_core/network/juce_URL.h | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 2350e8a135..46b1d3cf04 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -222,6 +222,13 @@ int URL::getPort() const return colonPos > 0 ? url.substring (colonPos + 1).getIntValue() : 0; } +URL URL::withNewDomainAndPath (const String& newURL) const +{ + URL u (*this); + u.url = newURL; + return u; +} + URL URL::withNewSubPath (const String& newPath) const { const int startOfPath = URLHelpers::findStartOfPath (url); diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index a2b3cb7657..aa7c154aa1 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -106,10 +106,19 @@ public: */ int getPort() const; - /** Returns a new version of this URL that uses a different sub-path. + /** Returns a new version of this URL with a different domain and path. + + E.g. if the URL is "http://www.xyz.com/foo?x=1" and you call this with + "abc.com/zzz", it'll return "http://abc.com/zzz?x=1". + @see withNewSubPath + */ + URL withNewDomainAndPath (const String& newFullPath) const; + + /** Returns a new version of this URL with a different sub-path. E.g. if the URL is "http://www.xyz.com/foo?x=1" and you call this with "bar", it'll return "http://www.xyz.com/bar?x=1". + @see withNewDomainAndPath */ URL withNewSubPath (const String& newPath) const;