static Uri ()
{
-#if NET_4_5
IriParsing = true;
-#endif
var iriparsingVar = Environment.GetEnvironmentVariable ("MONO_URI_IRIPARSING");
if (iriparsingVar == "true")
}
} else {
path = baseEl.path;
-#if !NET_4_0
- if (relativeEl.query != null) {
- var pathEnd = path.LastIndexOf ('/');
- path = (pathEnd > 0)? path.Substring (0, pathEnd+1) : "";
- }
-#endif
}
if ((path.Length == 0 || path [0] != '/') && baseEl.delimiter == SchemeDelimiter)
//
public Uri MakeRelativeUri (Uri uri)
{
-#if NET_4_0
if (uri == null)
throw new ArgumentNullException ("uri");
-#endif
if (Host != uri.Host || Scheme != uri.Scheme)
return uri;
private UriParser Parser {
get {
if (parser == null) {
- parser = UriParser.GetParser (Scheme);
+ parser = UriParser.GetParser (scheme);
// no specific parser ? then use a default one
if (parser == null)
parser = new DefaultUriParser ("*");
public string GetComponents (UriComponents components, UriFormat format)
{
+ if ((components & UriComponents.SerializationInfoString) == 0)
+ EnsureAbsoluteUri ();
+
return Parser.GetComponents (this, components, format);
}
public bool IsBaseOf (Uri uri)
{
-#if NET_4_0
if (uri == null)
throw new ArgumentNullException ("uri");
-#endif
return Parser.IsBaseOf (this, uri);
}
if ((uri1 == null) && (uri2 == null))
return 0;
+ if (uri1 == null)
+ return -1;
+ if (uri2 == null)
+ return 1;
string s1 = uri1.GetComponents (partsToCompare, compareFormat);
string s2 = uri2.GetComponents (partsToCompare, compareFormat);
return false;
}
-#if !NET_4_5
- switch (b) {
- case '!':
- case '\'':
- case '(':
- case ')':
- case '*':
- case '-':
- case '.':
- return false;
- }
-#endif
return true;
}
case '_':
case '~':
return false;
-#if NET_4_5
case '[':
case ']':
return false;
-#endif
}
return true;
result = null;
if ((baseUri == null) || !baseUri.IsAbsoluteUri)
return false;
-#if NET_4_0
if (relativeUri == null)
return false;
-#endif
try {
// FIXME: this should call UriParser.Resolve
result = new Uri (baseUri, relativeUri.OriginalString);