From 02571366ae2e956932425f9b5a56057ea4b8a643 Mon Sep 17 00:00:00 2001 From: rolman243 Date: Sat, 24 Aug 2024 20:05:19 +0200 Subject: [PATCH] feat: allow tld in ValidURL with 63 characters (#260) Fix for Issue #259 Co-authored-by: Roland Manfrahs --- main/src/io/github/iltotore/iron/constraint/string.scala | 2 +- main/test/src/io/github/iltotore/iron/testing/StringSuite.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main/src/io/github/iltotore/iron/constraint/string.scala b/main/src/io/github/iltotore/iron/constraint/string.scala index 6b6481aa..a8d36433 100644 --- a/main/src/io/github/iltotore/iron/constraint/string.scala +++ b/main/src/io/github/iltotore/iron/constraint/string.scala @@ -72,7 +72,7 @@ object string: */ type ValidURL = Match[ - "((\\w+:)+\\/\\/)?(([-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6})|(localhost))(:\\d{1,5})?(\\/|\\/([-a-zA-Z0-9@:%_\\+.~#?&//=]*))?" + "((\\w+:)+\\/\\/)?(([-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,63})|(localhost))(:\\d{1,5})?(\\/|\\/([-a-zA-Z0-9@:%_\\+.~#?&//=]*))?" ] DescribedAs "Should be an URL" /** diff --git a/main/test/src/io/github/iltotore/iron/testing/StringSuite.scala b/main/test/src/io/github/iltotore/iron/testing/StringSuite.scala index f12993ba..2f847996 100644 --- a/main/test/src/io/github/iltotore/iron/testing/StringSuite.scala +++ b/main/test/src/io/github/iltotore/iron/testing/StringSuite.scala @@ -64,6 +64,7 @@ object StringSuite extends TestSuite: test - "http://example.com/#section".assertRefine[ValidURL] test - "http://example.com/?q=with%20space".assertRefine[ValidURL] test - "http://example.com/?q=with+space".assertRefine[ValidURL] + test - "https://aaaaa-bbb-cccccc-dddddddd.eeeeeeee-fff.ggg.hhhhhhhhh:1234".assertRefine[ValidURL] test - "/example.com".assertNotRefine[ValidURL] test - "://example.com".assertNotRefine[ValidURL] test - "http:///".assertNotRefine[ValidURL]