Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository slug lowercase #70

Merged
merged 4 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ obj/
_ReSharper*/
*sln.dotsettings
/packages/
!packages/repositories.config
!packages/repositories.config
/.vs/SharpBucket/v15/Server/sqlite3
Copy link
Collaborator

@mnivet mnivet Nov 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be just /.vs/

Suggested change
/.vs/SharpBucket/v15/Server/sqlite3
/.vs/

9 changes: 8 additions & 1 deletion SharpBucket/V2/EndPoints/RepositoriesEndPoint.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using SharpBucket.V2.Pocos;
using Comment = SharpBucket.V2.Pocos.Comment;
using Repository = SharpBucket.V2.Pocos.Repository;
Expand Down Expand Up @@ -89,10 +90,16 @@ internal Repository DeleteRepository(string accountName, string repository)
return _sharpBucketV2.Delete(new Repository(), overrideUrl);
}

private string ParseSlug(string repositoryName)
{
var slugRegex = new Regex(@"[^a-zA-Z\.\-_0-9]+");
return slugRegex.Replace(repositoryName, "-").ToLowerInvariant();
}

private string GetRepositoryUrl(string accountName, string repository, string append)
{
var format = _baseUrl + "{0}/{1}/{2}";
return string.Format(format, accountName, repository, append);
return string.Format(format, accountName, ParseSlug(repository), append);
}

internal List<Watcher> ListWatchers(string accountName, string repository, int max = 0)
Expand Down