mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 11:24:44 +00:00
[bug]: Fixed a bug that content cannot be retrieved if "#" is included in a file or folder name.
This commit is contained in:
@@ -89,5 +89,30 @@ namespace Octokit.Tests.Helpers
|
||||
Assert.Equal("\\\"test milestone\\\"", input.EscapeDoubleQuotes());
|
||||
}
|
||||
}
|
||||
|
||||
public class EncodeSharpMethod
|
||||
{
|
||||
[Fact]
|
||||
public void EncodeSharpReturnsNullForNullInput()
|
||||
{
|
||||
Assert.Equal(string.Empty, (null as string).EncodeSharp());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EncodeSharpReturnsInputWithoutDoubleQuotes()
|
||||
{
|
||||
string input = "some test input without double quotes in it";
|
||||
|
||||
Assert.Equal(input, input.EncodeSharp());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EncodeAllSharp()
|
||||
{
|
||||
string input = "#some test input with # in it#";
|
||||
|
||||
Assert.Equal("%23some test input with %23 in it%23", input.EncodeSharp());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ namespace Octokit
|
||||
public static Uri FormatUri(this string pattern, params object[] args)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(pattern, nameof(pattern));
|
||||
var uriString = string.Format(CultureInfo.InvariantCulture, pattern, args).EncodeSharp();
|
||||
|
||||
return new Uri(string.Format(CultureInfo.InvariantCulture, pattern, args), UriKind.Relative);
|
||||
return new Uri(uriString, UriKind.Relative);
|
||||
}
|
||||
|
||||
public static string UriEncode(this string input)
|
||||
@@ -106,6 +107,11 @@ namespace Octokit
|
||||
return value;
|
||||
}
|
||||
|
||||
internal static string EncodeSharp(this string value)
|
||||
{
|
||||
return !string.IsNullOrEmpty(value) ? value?.Replace("#", "%23") : string.Empty;
|
||||
}
|
||||
|
||||
static IEnumerable<string> SplitUpperCase(this string source)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(source, nameof(source));
|
||||
|
||||
Reference in New Issue
Block a user