Skip to content

Instantly share code, notes, and snippets.

@maximilian-krauss
Created August 22, 2013 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximilian-krauss/6304414 to your computer and use it in GitHub Desktop.
Save maximilian-krauss/6304414 to your computer and use it in GitHub Desktop.
UriHelper
static class UriHelper {
public static Uri Combine(params string[] parts) {
var raw = new StringBuilder();
for (int i = 0; i < parts.Length; i++) {
var p = parts[i];
if (p.StartsWith("/"))
p = p.Substring(1);
raw.Append(
p.EndsWith("/") || i == parts.Length - 1 ? p : p + "/"
);
}
return new Uri(raw.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment