I'm looking for a clean method of changing the filename of an absolute or relative uri, that may contain multiple segments. We don't know if its absolute or relative in advance, so we need to detect that:

Here's the test case:

```
    [Test]
    public void Can_change_path_file_name()
    {
        Fix("file.txt").ShouldEqual("file_fixed.txt");
        Fix("/file.txt").ShouldEqual("/file_fixed.txt");
        Fix("directory/file.txt").ShouldEqual("directory/file_fixed.txt");
        Fix("/directory/file.txt").ShouldEqual("/directory/file_fixed.txt");
        Fix("/directory/subdirectory/file.txt").ShouldEqual("/directory/subdirectory/file_fixed.txt");
        Fix("http://www.test.com/directory/subdirectory/file.txt").ShouldEqual("http://www.test.com/directory/subdirectory/file_fixed.txt");
        Fix("/directory/file/file.txt").ShouldEqual("/directory/file/file_fixed.txt");
    }

    private string Fix(string uri)
    {
       // fill me with goodness
    }

```

My solution works but seems a bit involved. I've posted it below in case you want to better it:

```
private string Fix(string uri)
{
    var fileName = Path.GetFileNameWithoutExtension(uri);
    var extension = Path.GetExtension(uri);
    fileName += "_fixed" + extension;

    var path = uri.Contains('/') ? uri.Substring(0, uri.LastIndexOf('/') + 1) : "";
    return Combine(path, fileName);
}

private string Combine(string path1, string path2)
{
    if (path1 == null)
    {
        throw new ArgumentNullException("path1");
    }

    if (path2 == null)
    {
        throw new ArgumentNullException("path2");
    }

    if (String.IsNullOrEmpty(path2))
    {
        return path1;
    }

    if (String.IsNullOrEmpty(path1))
    {
        return path2;
    }

    if (path2.StartsWith("http://") || path2.StartsWith("https://"))
    {
        return path2;
    }

    var ch = path1[path1.Length - 1];

    if (ch != '/')
    {
        return (path1.TrimEnd('/') + '/' + path2.TrimStart('/'));
    }

    return (path1 + path2);
}

```