mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add url validation to SnapshotService
This commit is contained in:
parent
3d82ef3c3e
commit
b5baa417c2
1 changed files with 6 additions and 0 deletions
|
|
@ -42,6 +42,8 @@ public Snapshot(FilterListsDbContext dbContext, EmailService emailService, Filte
|
|||
public async Task TrySaveAsync()
|
||||
{
|
||||
await AddSnapEntity();
|
||||
if (!IsViewUrlValid())
|
||||
return;
|
||||
try
|
||||
{
|
||||
await SaveAsync();
|
||||
|
|
@ -57,6 +59,10 @@ private async Task AddSnapEntity()
|
|||
dbContext.Snapshots.Add(snapEntity);
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private bool IsViewUrlValid() =>
|
||||
Uri.TryCreate(list.ViewUrl, UriKind.Absolute, out var uriResult) &&
|
||||
(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue