Browse Source

fix electron side-panel banner

imwald
Silberengel 4 weeks ago
parent
commit
1d21f471c9
  1. 4
      package-lock.json
  2. 2
      package.json
  3. 11
      src/constants.ts

4
package-lock.json generated

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
{
"name": "imwald",
"version": "22.0.1",
"version": "22.0.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "imwald",
"version": "22.0.1",
"version": "22.0.2",
"license": "MIT",
"dependencies": {
"@asciidoctor/core": "^3.0.4",

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "imwald",
"version": "22.0.1",
"version": "22.0.2",
"description": "Imwald — a user-friendly Nostr client focused on relay feed browsing, publications, and relay discovery",
"private": true,
"type": "module",

11
src/constants.ts

@ -34,9 +34,20 @@ export const HIVETALK_BASE_URL = @@ -34,9 +34,20 @@ export const HIVETALK_BASE_URL =
/**
* URL for a file from `public/` (banner, favicon, payto logos, etc.).
* Uses Vite `base`: `/` on the web, `./` when built for Electron (`loadFile` + `file:`).
*
* Electron packaged builds use `file:` + client-side history paths like `/notes/…`, which replace
* the document URL with `file:///notes/…`. Relative `BASE_URL` links would then resolve next to that
* bogus path and 404. Resolve from this module's emitted chunk (`dist/assets/*.js`) instead.
*/
export function publicAssetUrl(assetPath: string): string {
const trimmed = assetPath.replace(/^\//, '')
if (typeof window !== 'undefined' && window.location.protocol === 'file:') {
try {
return new URL(`../../${trimmed}`, import.meta.url).href
} catch {
// fall through to BASE_URL
}
}
return `${import.meta.env.BASE_URL}${trimmed}`
}

Loading…
Cancel
Save