diff --git a/scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala b/scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala index d36ff0ac0392..545d9176675a 100644 --- a/scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala +++ b/scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala @@ -14,7 +14,7 @@ object SocialLinks: val errorPrefix = s"Social links arg $s is invalid: " val splitted = s.split("::") - splitted.head match { + splitted.head.toLowerCase match { case "github" if splitted.size == 2 => Right(Github(splitted(1))) case "github" => Left(errorPrefix + "For 'github' arg expected one argument: url") case "twitter" if splitted.size == 2 => Right(Twitter(splitted(1))) @@ -25,6 +25,6 @@ object SocialLinks: case "discord" => Left(errorPrefix + "For 'discord' arg expected one argument: url") case LowercaseNamePattern() if splitted.size == 4 => Right(Custom(splitted(1), splitted(2), splitted(3))) case LowercaseNamePattern() if splitted.size == 3 => Right(Custom(splitted(1), splitted(2), splitted(2))) - case LowercaseNamePattern() => Left(errorPrefix + "For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]") + case LowercaseNamePattern() => Left(errorPrefix + "For the 'custom' link, a minimum of two arguments is expected: URL, light icon file name, [dark icon file name]") case _ => Left(errorPrefix) } diff --git a/scaladoc/test/dotty/tools/scaladoc/SocialLinksTest.scala b/scaladoc/test/dotty/tools/scaladoc/SocialLinksTest.scala index 3150761e6ea2..ede928ff2a08 100644 --- a/scaladoc/test/dotty/tools/scaladoc/SocialLinksTest.scala +++ b/scaladoc/test/dotty/tools/scaladoc/SocialLinksTest.scala @@ -36,12 +36,17 @@ class SocialLinksTest: val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom-dark") assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null)) + @Test def customLinkUpper(): Unit = + val customLink = "Namecustom::https://custom.com/test::custom" + val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom") + assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null)) + @Test def parseRegexError(): Unit = - val regexErrorLink = "nameCustom::https://custom.com/test::custom::custom-dark::custom" + val regexErrorLink = "nameCustom3::https://custom.com/test::custom::custom-dark::custom" val expected = s"Social links arg $regexErrorLink is invalid: " assertEquals(expected, SocialLinks.parse(regexErrorLink).left.getOrElse(null)) @Test def parseLinkWithError(): Unit = val errorLink = "namecustom::https://custom.com/test::custom::custom-dark::custom" - val expected = s"Social links arg $errorLink is invalid: For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]" + val expected = s"Social links arg $errorLink is invalid: For the 'custom' link, a minimum of two arguments is expected: URL, light icon file name, [dark icon file name]" assertEquals(expected, SocialLinks.parse(errorLink).left.getOrElse(null))