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

Make Shortner case insensitive #501

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,12 @@ src/adminTools/adminBlazorWebsite/src/appsettings.Development.json

#Igniore VSCode User Setting
**/.vscode/settings.json

# Azurite Files (note - https://github.com/Azure/Azurite/pull/1061)
__azurite_db_blob_extent__.json
__azurite_db_blob__.json
__azurite_db_queue__.json
__azurite_db_table__.json
__azurite_db_queue_extent__.json
__blobstorage__
__queuestorage__
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public ClickStatsEntity() { }

public ClickStatsEntity(string vanity)
{
PartitionKey = vanity;
PartitionKey = vanity.ToLower();;
RowKey = Guid.NewGuid().ToString();
Datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public async Task<List<ShortUrlEntity>> GetAllShortUrlEntities()
/// <returns>ShortUrlEntity</returns>
public async Task<ShortUrlEntity> GetShortUrlEntityByVanity(string vanity)
{
vanity = vanity.ToLower();
var tblUrls = GetUrlsTable();
TableContinuationToken token = null;
ShortUrlEntity shortUrlEntity = null;
Expand Down Expand Up @@ -169,7 +170,7 @@ public async Task<List<ClickStatsEntity>> GetAllStatsByVanity(string vanity)
}
else{
rangeQuery = new TableQuery<ClickStatsEntity>().Where(
filter: TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, vanity));
filter: TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, vanity.ToLower()));
}

var queryResult = await tblUrls.ExecuteQuerySegmentedAsync(rangeQuery, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ ExecutionContext context

string longUrl = input.Url.Trim();
string vanity = string.IsNullOrWhiteSpace(input.Vanity) ? "" : input.Vanity.Trim();
vanity = vanity.ToLower();
string title = string.IsNullOrWhiteSpace(input.Title) ? "" : input.Title.Trim();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public async Task<HttpResponseData> Run(
ExecutionContext context)
{
string redirectUrl = "https://azure.com";
shortUrl = shortUrl.ToLower();


if (!string.IsNullOrWhiteSpace(shortUrl))
Expand Down
6 changes: 3 additions & 3 deletions src/Cloud5mins.ShortenerTools.Functions/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public static async Task<string> GetValidEndUrl(string vanity, StorageTableHelpe
if (await stgHelper.IfShortUrlEntityExistByVanity(getCode()))
return await GetValidEndUrl(vanity, stgHelper);

return string.Join(string.Empty, getCode());
return string.Join(string.Empty, getCode()).ToLower();
}
else
{
return string.Join(string.Empty, vanity);
return string.Join(string.Empty, vanity).ToLower();
}
}

Expand All @@ -48,7 +48,7 @@ public static string Encode(int i)

public static string GetShortUrl(string host, string vanity)
{
return host + "/" + vanity;
return host + "/" + vanity?.ToLower();
}

// generates a unique, random, and alphanumeric token for the use as a url
Expand Down