test(embeds): add registry, pair-aware sanitizer, hydration tests, and README docs
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
/** Allowed embed provider key format (mirrors sm-journal-plugin). */
|
||||
export const EMBED_PROVIDER_KEY = /^[a-z][a-z0-9_-]{0,31}$/
|
||||
|
||||
const RESERVED_PROVIDER_KEYS = new Set(['constructor', 'prototype'])
|
||||
|
||||
/** Allowed `data-aspect` token (e.g. `16/9`, `4 / 3`, `1.5`), zero CSS injection vectors. */
|
||||
export const EMBED_ASPECT = /^[1-9][0-9]{0,3}(?:\s*\/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$/
|
||||
|
||||
@@ -122,7 +124,7 @@ function normalizeIdPattern(name: string, pattern: RegExp | string): RegExp {
|
||||
}
|
||||
|
||||
function normalizeProvider(name: string, provider: JournalEmbedProvider): NormalizedJournalEmbedProvider {
|
||||
if (!EMBED_PROVIDER_KEY.test(name)) {
|
||||
if (!EMBED_PROVIDER_KEY.test(name) || RESERVED_PROVIDER_KEYS.has(name)) {
|
||||
throw new Error(`Invalid journal embed provider key "${name}": must match ${EMBED_PROVIDER_KEY.source}`)
|
||||
}
|
||||
if (!provider || typeof provider !== 'object') {
|
||||
|
||||
Reference in New Issue
Block a user