ChemPal Documentation - v1.6.0
    Preparing search index...

    Function stripSchemaEnumPrefix

    • 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, @id links, and off-site URLs are returned unchanged.

      Parameters

      • value: string

        A string that may be a schema.org enumeration URL.

      Returns string

      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;
      }