Skip to content

Commit 4f03d10

Browse files
Lucas LeblancKordyjan
Lucas Leblanc
authored andcommitted
Add toLowerCase to accept more unfortunate errors
[Cherry-picked a9f4008]
1 parent 1bb9137 commit 4f03d10

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object SocialLinks:
1414
val errorPrefix = s"Social links arg $s is invalid: "
1515
val splitted = s.split("::")
1616

17-
splitted.head match {
17+
splitted.head.toLowerCase match {
1818
case "github" if splitted.size == 2 => Right(Github(splitted(1)))
1919
case "github" => Left(errorPrefix + "For 'github' arg expected one argument: url")
2020
case "twitter" if splitted.size == 2 => Right(Twitter(splitted(1)))
@@ -25,6 +25,6 @@ object SocialLinks:
2525
case "discord" => Left(errorPrefix + "For 'discord' arg expected one argument: url")
2626
case LowercaseNamePattern() if splitted.size == 4 => Right(Custom(splitted(1), splitted(2), splitted(3)))
2727
case LowercaseNamePattern() if splitted.size == 3 => Right(Custom(splitted(1), splitted(2), splitted(2)))
28-
case LowercaseNamePattern() => Left(errorPrefix + "For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]")
28+
case LowercaseNamePattern() => Left(errorPrefix + "For the 'custom' link, a minimum of two arguments is expected: URL, light icon file name, [dark icon file name]")
2929
case _ => Left(errorPrefix)
3030
}

scaladoc/test/dotty/tools/scaladoc/SocialLinksTest.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ class SocialLinksTest:
3636
val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom-dark")
3737
assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null))
3838

39+
@Test def customLinkUpper(): Unit =
40+
val customLink = "Namecustom::https://custom.com/test::custom"
41+
val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom")
42+
assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null))
43+
3944
@Test def parseRegexError(): Unit =
40-
val regexErrorLink = "nameCustom::https://custom.com/test::custom::custom-dark::custom"
45+
val regexErrorLink = "nameCustom3::https://custom.com/test::custom::custom-dark::custom"
4146
val expected = s"Social links arg $regexErrorLink is invalid: "
4247
assertEquals(expected, SocialLinks.parse(regexErrorLink).left.getOrElse(null))
4348

4449
@Test def parseLinkWithError(): Unit =
4550
val errorLink = "namecustom::https://custom.com/test::custom::custom-dark::custom"
46-
val expected = s"Social links arg $errorLink is invalid: For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]"
51+
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]"
4752
assertEquals(expected, SocialLinks.parse(errorLink).left.getOrElse(null))

0 commit comments

Comments
 (0)