Skip to content

Commit

Permalink
Also handle empty/one-element list
Browse files Browse the repository at this point in the history
  • Loading branch information
marzipankaiser committed Sep 11, 2024
1 parent 015cd26 commit 4b125b1
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions effekt/shared/src/main/scala/effekt/generator/js/Transformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ trait Transformer {

// Externs
// -------
def normalizeExternStrings(l: List[String])(using Context): List[String] = {
val start = l.head
val end = l.last
val mid = l.tail.init
if (start.matches("""^\s.*""") || end.matches(""".*\s$""")) {
Context.warning("Extern string in js has trailing / leading whitespace. This will be removed.")
}
start.stripLeading() +: mid :+ end.stripTrailing()
def normalizeExternStrings(l: List[String])(using Context): List[String] = l match {
case Nil => Nil
case List(s) =>
if (s.matches("""^\s.*""") || s.matches(""".*\s$""")) {
Context.warning("Extern string in js has trailing / leading whitespace. This will be removed.")
}
List(s.strip())
case l =>
val start = l.head
val end = l.last
val mid = l.tail.init
if (start.matches("""^\s.*""") || end.matches(""".*\s$""")) {
Context.warning("Extern string in js has trailing / leading whitespace. This will be removed.")
}
start.stripLeading() +: mid :+ end.stripTrailing()
}

// Separate Compilation (Website)
Expand Down

0 comments on commit 4b125b1

Please sign in to comment.