Skip to content

Commit

Permalink
Merge pull request #104 from mfilippov/bug-77
Browse files Browse the repository at this point in the history
Fix parsing id from URL. #77
  • Loading branch information
mfilippov authored Sep 29, 2017
2 parents 3d2ac02 + b60b01c commit 1e331a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/VimeoDotNet.Tests/Helpers/ModelHelpersTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Shouldly;
using VimeoDotNet.Helpers;
using Xunit;

namespace VimeoDotNet.Tests.Helpers
{
public class ModelHelpersTests
{
[Fact]
public void ShouldCorrectlyParseId()
{
ModelHelpers.ParseModelUriId("/a/b/c/12345").ShouldBe(12345);
ModelHelpers.ParseModelUriId("/a/b/c/12345:xyz").ShouldBe(12345);
}
}
}
1 change: 1 addition & 0 deletions src/VimeoDotNet.Tests/VimeoDotNet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
</Choose>
<ItemGroup>
<Compile Include="AuthorizationClientAsyncTests.cs" />
<Compile Include="Helpers\ModelHelpersTests.cs" />
<Compile Include="Settings\SettingsLoader.cs" />
<Compile Include="Settings\VimeoApiTestSettings.cs" />
<Compile Include="VimeoClientAsyncTests.cs" />
Expand Down
9 changes: 7 additions & 2 deletions src/VimeoDotNet/Helpers/ModelHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ internal static class ModelHelpers
{
return null;
}
string[] pieces = uri.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
var pieces = uri.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
long userId = 0;
if (long.TryParse(pieces[pieces.Length - 1], out userId))
var idString = pieces[pieces.Length - 1];
if (idString.Contains(":"))
{
idString = idString.Split(':')[0];
}
if (long.TryParse(idString, out userId))
{
return userId;
}
Expand Down
2 changes: 2 additions & 0 deletions src/VimeoDotNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("VimeoDotNet")]
Expand All @@ -7,6 +8,7 @@
[assembly: AssemblyCopyright("Copyright © 2014-2016, Stephen Commisso, Mikhael Filippov")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: InternalsVisibleTo("VimeoDotNet.Tests")]

[assembly: AssemblyDescription("Core library for accessing the Vimeo REST API")]

Expand Down

0 comments on commit 1e331a8

Please sign in to comment.