Files
apes-sidebar/tests/desktop-env.spec.ts
T
Menghuan1918 ba7d069842 fix(preview): render data images and self-contain desktop HTML previews
Markdown syntax now passes data:image/* through the image vocabulary (the host allowlist already accepts it); every other data payload stays inert. The desktop shell's sandboxed HTML preview is self-contained: the trusted top frame fetches the document and its same-origin assets, inlines them, and frames a sandboxed blob instead of a dsh-app route the shell rejects from an opaque subframe. The sandbox never gains allow-same-origin; browser and explicitly-unsandboxed paths are unchanged.
2026-11-11 21:28:39 +08:00

22 lines
896 B
TypeScript

/**
* Desktop-shell page detection. The inlining branch must be selected only for
* the official `dsh-app:` page; ordinary http(s) deployments (including a
* reverse-proxied one) keep the route-src HTML preview.
*/
import { describe, expect, it } from 'vitest'
import { isDesktopShell } from '../src/client/desktop-env.ts'
describe('isDesktopShell', () => {
it('is true for the desktop shell page origin', () => {
expect(isDesktopShell('dsh-app://app/')).toBe(true)
expect(isDesktopShell('dsh-app://app/sidebar/html/s1/p/a.html')).toBe(true)
})
it('is false for web deployments, proxy prefixes and empty/invalid bases', () => {
expect(isDesktopShell('http://127.0.0.1:3080/')).toBe(false)
expect(isDesktopShell('https://host.example.test/proxy/3080/')).toBe(false)
expect(isDesktopShell('')).toBe(false)
expect(isDesktopShell('not a url')).toBe(false)
})
})