UNPKG

vega-schema-url-parser

Version:

A parser to get the library and version from Vega and Vega-Lite schema URLs.

9 lines (8 loc) 286 B
/** * Parse a vega schema url into library and version. */ export default function(url: string) { const regex = /schema\/([\w-]+)\/([\w\.\-]+)\.json$/g; const [library, version] = regex.exec(url)!.slice(1, 3); return {library: library as 'vega' | 'vega-lite', version}; }