diff --git a/crates/mako/src/config.rs b/crates/mako/src/config.rs index b1c380e68..8b361f94b 100644 --- a/crates/mako/src/config.rs +++ b/crates/mako/src/config.rs @@ -295,7 +295,7 @@ mod tests { } #[test] - #[should_panic(expected = "public_path must end with '/' or be 'runtime'")] + #[should_panic(expected = "publicPath must end with '/' and start with '/' or be 'runtime'")] fn test_config_invalid_public_path() { let current_dir = std::env::current_dir().unwrap(); Config::new( diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking.snap index 80aa0ba68..816e97193 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_class.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_class.snap index c225b36a2..61afa5d70 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_class.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_class.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_dynamic_import.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_dynamic_import.snap index 6eba9d37b..5056a7362 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_dynamic_import.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_dynamic_import.snap @@ -149,7 +149,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -256,7 +256,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -295,7 +295,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_default.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_default.snap index fc2e2230a..6de107ca3 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_default.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_default.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_namespace.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_namespace.snap index dbd8c8e46..1c9bc2293 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_namespace.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_export_namespace.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_exported.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_exported.snap index 29121df78..4f10e8306 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_exported.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_exported.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_fn.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_fn.snap index 02ea6366d..5d6f1521a 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_fn.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_fn.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_issues_271.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_issues_271.snap index d1dd7ddf1..02ab7932e 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_issues_271.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_issues_271.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_jsx.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_jsx.snap index 1993e1a5f..20bae1eb1 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_jsx.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_jsx.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_export.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_export.snap index 882541f79..7082a7c0f 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_export.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_export.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_reexport.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_reexport.snap index 8bdd00858..e0f9b8553 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_reexport.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_named_reexport.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_reexport.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_reexport.snap index 8f6a285bc..460624921 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_reexport.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_reexport.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_require_esm.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_require_esm.snap index 045e9efab..cd155327d 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_require_esm.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_require_esm.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_side_effect.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_side_effect.snap index 73a931da7..9f288f733 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_side_effect.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_side_effect.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') { diff --git a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_style.snap b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_style.snap index a6dde69ad..34c215f45 100644 --- a/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_style.snap +++ b/crates/mako/src/snapshots/mako__tree_shaking__tests__tree_shaking_style.snap @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) { check () { const current_hash = requireModule.currentHash(); const publicPath = requireModule.publicPath; - return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{ + return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ return res.json(); }).then((update)=>{ return Promise.all(update.c.map((chunk)=>{ @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) { } const script = document.createElement('script'); script.timeout = 120; - script.src = url?.startsWith('/') ? url : `/${url}`; + script.src = url; inProgress[url] = [ done ]; @@ -295,7 +295,7 @@ function createRuntime(makoModules, entryModuleId) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; - link.href = url?.startsWith('/') ? url : `/${url}`; + link.href = url; link.onerror = link.onload = function(event) { link.onerror = link.onload = null; if (event.type === 'load') {