Skip to content

Commit 0bc9b6d

Browse files
lx-0claude
andcommitted
fix: respect BASE_URL for runtime asset paths + swap gitleaks
- Hardcoded `/icons/icon.svg`, `/icons/avatar.svg`, `/wasm` only worked at root. On GH Pages subpath (`/browser-llm-demo/`) the BrandMark icon and MediaPipe WASM-loader 404'd. New `assetPath()` helper prepends `import.meta.env.BASE_URL`. - Gitleaks' proprietary action requires a paid license for GitHub orgs. Swapped to TruffleHog (OSS, MIT, free for orgs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a9769e7 commit 0bc9b6d

5 files changed

Lines changed: 21 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
- name: Build
3838
run: pnpm build
3939

40-
gitleaks:
40+
secrets-scan:
4141
runs-on: ubuntu-latest
4242
steps:
4343
- uses: actions/checkout@v4
4444
with:
4545
fetch-depth: 0
4646

47-
- uses: gitleaks/gitleaks-action@v2
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
- uses: trufflesecurity/trufflehog@main
48+
with:
49+
extra_args: --results=verified,unknown

src/components/atoms/Avatar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { assetPath } from "@/lib/asset-path.ts";
12
import { cn } from "@/lib/cn.ts";
23
import { type VariantProps, cva } from "class-variance-authority";
34

5+
const DEFAULT_AVATAR = assetPath("icons/avatar.svg");
6+
47
const avatarVariants = cva("overflow-hidden rounded-full bg-neutral-900 object-cover", {
58
variants: {
69
size: {
@@ -18,7 +21,7 @@ export type AvatarProps = VariantProps<typeof avatarVariants> & {
1821
className?: string;
1922
};
2023

21-
export function Avatar({ src = "/icons/avatar.svg", alt, size, className }: AvatarProps) {
24+
export function Avatar({ src = DEFAULT_AVATAR, alt, size, className }: AvatarProps) {
2225
return (
2326
<img
2427
src={src}

src/components/atoms/BrandMark.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { assetPath } from "@/lib/asset-path.ts";
12
import { cn } from "@/lib/cn.ts";
23
import { type VariantProps, cva } from "class-variance-authority";
34

5+
const ASSET_ICON = assetPath("icons/icon.svg");
6+
47
const brandVariants = cva("flex-none select-none", {
58
variants: {
69
size: {
@@ -19,7 +22,7 @@ export type BrandMarkProps = VariantProps<typeof brandVariants> & {
1922
export function BrandMark({ size, className }: BrandMarkProps) {
2023
return (
2124
<img
22-
src="/icons/icon.svg"
25+
src={ASSET_ICON}
2326
alt=""
2427
aria-hidden="true"
2528
draggable={false}

src/lib/asset-path.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Prepend Vite's runtime base URL (dev = "/", prod = PROJECT.basePath e.g.
2+
// "/browser-llm-demo/") to a relative asset path. Needed for JS-land refs
3+
// to public/ assets since Vite only rewrites absolute paths in index.html.
4+
export function assetPath(relative: string): string {
5+
const base = import.meta.env.BASE_URL;
6+
return base + relative.replace(/^\/+/, "");
7+
}

src/lib/mediapipe-llm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FilesetResolver, LlmInference } from "@mediapipe/tasks-genai";
2+
import { assetPath } from "./asset-path.ts";
23
import type { ModelId } from "./model-catalog.ts";
34
import { MODEL_CATALOG, getCacheKey, getModelUrl } from "./model-catalog.ts";
45
import { type DownloadProgress, loadModelWithCache } from "./opfs-cache.ts";
@@ -27,7 +28,7 @@ function nextSeed(): number {
2728
return Math.floor(Math.random() * 2 ** 31);
2829
}
2930

30-
const WASM_PATH = "/wasm";
31+
const WASM_PATH = assetPath("wasm");
3132

3233
// Gemma's decoder emits stop tokens as literal strings rather than halting.
3334
// Match Gemma turn-markers plus Unicode replacement + private-use-area glyphs.

0 commit comments

Comments
 (0)