Fixed an issue where if a route didn't end with a /, the generated code would still contain an ending slash. Bumped package version to 1.7.1

This commit is contained in:
MattMo 2023-07-11 09:52:15 -07:00
parent 69a1d9c3a8
commit 2f71c18b65
4 changed files with 19 additions and 5 deletions

View File

@ -406,6 +406,18 @@ namespace MontoyaTech.Rest.Net
return this;
}
/// <summary>
/// Returns the last character written to the writer if there was one, otherwise it returns character 0.
/// </summary>
/// <returns></returns>
public char Peek()
{
if (this.Builder.Length > 0)
return this.Builder[this.Builder.Length - 1];
else
return (char)0;
}
/// <summary>
/// Gets all the written data from the writer.
/// </summary>

View File

@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
</PropertyGroup>

View File

@ -448,10 +448,11 @@ namespace MontoyaTech.Rest.Net
int argumentIndex = 0;
foreach (var component in components)
{
if (!string.IsNullOrWhiteSpace(component))
{
if (writer.Peek() != '/')
writer.Write('/');
if (!string.IsNullOrWhiteSpace(component))
{
if (component.StartsWith("{"))
{
writer.Write("{").Write(parameters[argumentIndex++ + 1].Name).Write("}");

View File

@ -549,10 +549,11 @@ namespace MontoyaTech.Rest.Net
int argumentIndex = 0;
foreach (var component in components)
{
if (!string.IsNullOrWhiteSpace(component))
{
if (writer.Peek() != '/')
writer.Write('/');
if (!string.IsNullOrWhiteSpace(component))
{
if (component.StartsWith("{"))
{
writer.Write("${").Write(parameters[argumentIndex++ + 1].Name).Write("}");