Skip to content

Commit 80f9660

Browse files
CopilotQuafadas
andcommitted
Restore basePath="./" and fix tests to match "./" prefix for GitHub Pages compatibility
Agent-Logs-Url: https://github.com/Quafadas/live-server-scala-cli-js/sessions/f5cf85b5-432c-4dbe-92cd-30fde33d8cae Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
1 parent ffc3c8b commit 80f9660

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

plugin/integration/src/normal.test.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ object WebAppModuleTests extends TestSuite:
3838
val html = os.read(siteDir / "index.html")
3939

4040
// 1. Must NOT reference the static unhashed name
41-
assert(!html.contains("src=\"/main.js\""))
41+
assert(!html.contains("src=\"./main.js\""))
4242

4343
// 2. Extract all <script src="..."> references from the HTML
44-
val scriptSrcPattern = """src="/([^"]+\.js)"""".r
44+
val scriptSrcPattern = """src="\./([^"]+\.js)"""".r
4545
val scriptRefs = scriptSrcPattern.findAllMatchIn(html).map(_.group(1)).toList
4646
if scriptRefs.isEmpty then
4747
throw new java.lang.AssertionError(s"No <script src=...> found in index.html:\n$html")
@@ -180,7 +180,7 @@ object WebAppModuleTests extends TestSuite:
180180
end if
181181

182182
// Extract all <script src="..."> references
183-
val scriptSrcPattern = """src="/([^"]+\.js)"""".r
183+
val scriptSrcPattern = """src="\./([^"]+\.js)"""".r
184184
val scriptRefs = scriptSrcPattern.findAllMatchIn(html).map(_.group(1)).toList
185185
if scriptRefs.isEmpty then
186186
throw new java.lang.AssertionError(s"No <script src=...> found in publish index.html:\n$html")

plugin/src/refresh_plugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ trait ScalaJsRefreshModule extends ScalaJSConfigModule:
4646

4747
def titleString: String = "App"
4848

49-
def bodyHtmlFromReport(report: Report, basePath: String = "/", includeRefresh: Boolean = false): String =
49+
def bodyHtmlFromReport(report: Report, basePath: String = "./", includeRefresh: Boolean = false): String =
5050
val scriptTags = report.publicModules.map(m => script(src := s"$basePath${m.jsFileName}", `type` := "module"))
5151
body(
5252
frag(scriptTags.toSeq*),

0 commit comments

Comments
 (0)