Skip to content

Commit

Permalink
handle numeric input (#11885)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Jul 5, 2021
1 parent 370e8c8 commit 3f70c8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ExtendedUriParserTests
[TestCase("localhost", true, "http://localhost/")]
[TestCase("127.0.0.1", true, "http://127.0.0.1/")]
[TestCase("127.0.0.1:80", true, "http://127.0.0.1/")]
[TestCase("127", true, "http://0.0.0.127/")]
[TestCase("127", false, null)]
[TestCase("", false, null)]
[TestCase("https://google.com", true, "https://google.com/")]
[TestCase("ftps://google.com", true, "ftps://google.com/")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Linq;
using Microsoft.Plugin.Uri.Interfaces;

namespace Microsoft.Plugin.Uri.UriHelper
Expand All @@ -21,7 +22,8 @@ public bool TryParse(string input, out System.Uri result)
// Using CurrentCulture since this is a user typed string
if (input.EndsWith(":", StringComparison.CurrentCulture)
|| input.EndsWith(".", StringComparison.CurrentCulture)
|| input.EndsWith(":/", StringComparison.CurrentCulture))
|| input.EndsWith(":/", StringComparison.CurrentCulture)
|| input.All(char.IsDigit))
{
result = default;
return false;
Expand Down

0 comments on commit 3f70c8c

Please sign in to comment.