From 9a511e9d21e4c35dad2c22a8f84f9a8f4755078b Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 11 Jun 2025 15:10:10 +0200 Subject: [PATCH 1/6] Test JS builds --- build.sbt | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 9f39cad..db45a86 100644 --- a/build.sbt +++ b/build.sbt @@ -87,7 +87,38 @@ lazy val core = (projectMatrix in file("core")) ) .jsPlatform( scalaVersions = scala2 ++ scala3, - settings = commonJsSettings ++ browserChromeTestSettings ++ Seq( + settings = commonJsSettings ++ downloadChromeDriverSettings ++ browserCommonTestSetting ++ Seq( + jsEnv in Test := { + val debugging = false // set to true to help debugging + System.setProperty("webdriver.chrome.driver", "target/chromedriver") + new org.scalajs.jsenv.selenium.SeleniumJSEnv( + { + val options = new org.openqa.selenium.chrome.ChromeOptions() + val args = Seq( + "auto-open-devtools-for-tabs", // devtools needs to be open to capture network requests + "no-sandbox", + "allow-file-access-from-files", // change the origin header from 'null' to 'file' + "user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", + "headless=new" + ) ++ (if (debugging) Seq.empty else Seq("headless")) + options.addArguments(args: _*) + val capabilities = + org.openqa.selenium.remote.DesiredCapabilities.chrome() + capabilities.setCapability( + org.openqa.selenium.chrome.ChromeOptions.CAPABILITY, + options + ) + capabilities + }, + org.scalajs.jsenv.selenium.SeleniumJSEnv + .Config() + .withKeepAlive(debugging) + ) + }, + test in Test := (test in Test) + .dependsOn(downloadChromeDriver) + .value + ) ++ Seq( libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.6.0" ) ) From ae39b7e490ca9cb1e207fc7e84d4308aed09a6f0 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 11 Jun 2025 15:35:37 +0200 Subject: [PATCH 2/6] Use playwright instead --- build.sbt | 38 +++---------------- .../model/internal/UriCompatibility.scala | 3 +- project/plugins.sbt | 2 + 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/build.sbt b/build.sbt index db45a86..2803c95 100644 --- a/build.sbt +++ b/build.sbt @@ -87,38 +87,12 @@ lazy val core = (projectMatrix in file("core")) ) .jsPlatform( scalaVersions = scala2 ++ scala3, - settings = commonJsSettings ++ downloadChromeDriverSettings ++ browserCommonTestSetting ++ Seq( - jsEnv in Test := { - val debugging = false // set to true to help debugging - System.setProperty("webdriver.chrome.driver", "target/chromedriver") - new org.scalajs.jsenv.selenium.SeleniumJSEnv( - { - val options = new org.openqa.selenium.chrome.ChromeOptions() - val args = Seq( - "auto-open-devtools-for-tabs", // devtools needs to be open to capture network requests - "no-sandbox", - "allow-file-access-from-files", // change the origin header from 'null' to 'file' - "user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", - "headless=new" - ) ++ (if (debugging) Seq.empty else Seq("headless")) - options.addArguments(args: _*) - val capabilities = - org.openqa.selenium.remote.DesiredCapabilities.chrome() - capabilities.setCapability( - org.openqa.selenium.chrome.ChromeOptions.CAPABILITY, - options - ) - capabilities - }, - org.scalajs.jsenv.selenium.SeleniumJSEnv - .Config() - .withKeepAlive(debugging) - ) - }, - test in Test := (test in Test) - .dependsOn(downloadChromeDriver) - .value - ) ++ Seq( + settings = commonJsSettings ++ browserCommonTestSetting ++ Seq( + Test / jsEnv := new jsenv.playwright.PWEnv( + browserName = "chrome", + headless = true, + showLogs = true + ), libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.6.0" ) ) diff --git a/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala b/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala index 87c13a1..dc9deb3 100644 --- a/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala +++ b/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala @@ -7,7 +7,8 @@ import scala.scalajs.js.URIUtils private[sttp] object UriCompatibility { def encodeDNSHost(s: String): String = { // the URL class IDN formats and escapes the host - new URL(s"http://$s").host + // new URL(s"http://$s").host + new URL(s"http://${URIUtils.encodeURIComponent(s)}").host } def encodeQuery(s: String, enc: String): String = URIUtils.encodeURIComponent(s) diff --git a/project/plugins.sbt b/project/plugins.sbt index d4b4a6d..fdaeb86 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -12,3 +12,5 @@ addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7") + +libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.11" From f62941fd69b9b4c0b0ff5ac22de0f07443888ac8 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 11 Jun 2025 16:12:22 +0200 Subject: [PATCH 3/6] Change config --- build.sbt | 2 +- project/plugins.sbt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 2803c95..b974bab 100644 --- a/build.sbt +++ b/build.sbt @@ -91,7 +91,7 @@ lazy val core = (projectMatrix in file("core")) Test / jsEnv := new jsenv.playwright.PWEnv( browserName = "chrome", headless = true, - showLogs = true + showLogs = false ), libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.6.0" ) diff --git a/project/plugins.sbt b/project/plugins.sbt index fdaeb86..4f60566 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,3 @@ -libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.19.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.7") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.11.0") From 786bc354b0b76635927b853ca32fc0e8e49ab35f Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 11 Jun 2025 16:18:43 +0200 Subject: [PATCH 4/6] Update java --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67ac6d9..44c6e6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: java-opts: '-Xmx4G' sttp-native: 1 install-libidn2: true + java-version: 21 # needed by Playwright (JS testing) mima: uses: softwaremill/github-actions-workflows/.github/workflows/mima.yml@main From 0cb17ef2951ba4e70e3489ba358b78a2482b1d90 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 11 Jun 2025 22:28:20 +0200 Subject: [PATCH 5/6] Update plugin --- .github/workflows/ci.yml | 1 - build.sbt | 7 +------ project/plugins.sbt | 4 +--- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44c6e6f..67ac6d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ jobs: java-opts: '-Xmx4G' sttp-native: 1 install-libidn2: true - java-version: 21 # needed by Playwright (JS testing) mima: uses: softwaremill/github-actions-workflows/.github/workflows/mima.yml@main diff --git a/build.sbt b/build.sbt index b974bab..9f39cad 100644 --- a/build.sbt +++ b/build.sbt @@ -87,12 +87,7 @@ lazy val core = (projectMatrix in file("core")) ) .jsPlatform( scalaVersions = scala2 ++ scala3, - settings = commonJsSettings ++ browserCommonTestSetting ++ Seq( - Test / jsEnv := new jsenv.playwright.PWEnv( - browserName = "chrome", - headless = true, - showLogs = false - ), + settings = commonJsSettings ++ browserChromeTestSettings ++ Seq( libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.6.0" ) ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4f60566..c107da8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,7 +2,7 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.19.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.7") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.11.0") -val sbtSoftwareMillVersion = "2.0.26" +val sbtSoftwareMillVersion = "2.1.0" addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion) addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion) addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-browser-test-js" % sbtSoftwareMillVersion) @@ -11,5 +11,3 @@ addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7") - -libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.11" From ccf770702242f24e7d1a0b911025acff5ce2f5d5 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 11 Jun 2025 22:28:51 +0200 Subject: [PATCH 6/6] Revert change --- .../main/scalajs/sttp/model/internal/UriCompatibility.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala b/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala index dc9deb3..87c13a1 100644 --- a/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala +++ b/core/src/main/scalajs/sttp/model/internal/UriCompatibility.scala @@ -7,8 +7,7 @@ import scala.scalajs.js.URIUtils private[sttp] object UriCompatibility { def encodeDNSHost(s: String): String = { // the URL class IDN formats and escapes the host - // new URL(s"http://$s").host - new URL(s"http://${URIUtils.encodeURIComponent(s)}").host + new URL(s"http://$s").host } def encodeQuery(s: String, enc: String): String = URIUtils.encodeURIComponent(s)