From c5c5b6e45095475f06b9a893e562db5340c0c6bd Mon Sep 17 00:00:00 2001 From: Roland Manfrahs Date: Sat, 24 Aug 2024 19:46:43 +0200 Subject: [PATCH] allow tld in ValidURL with 63 characters --- 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]