A string that may be a schema.org enumeration URL.
The bare member name when it matches, otherwise the original string.
stripSchemaEnumPrefix('https://schema.org/PreOrder'); // 'PreOrder'
stripSchemaEnumPrefix('https://schema.org/NewCondition'); // 'NewCondition'
stripSchemaEnumPrefix('https://schema.org'); // unchanged (context)
stripSchemaEnumPrefix('https://carolina.com/p/888770'); // unchanged (off-site)
export function stripSchemaEnumPrefix(value: string): string {
const match = SCHEMA_ENUM_RE.exec(value);
return match ? match[1] : value;
}
Strip a leading
http(s)://schema.org/from a schema.org enumeration value, leaving the bare member name (e.g."https://schema.org/InStock"becomes"InStock"). Only a single identifier segment is stripped, so real URLs, the@context,@idlinks, and off-site URLs are returned unchanged.