Project

General

Profile

« Previous | Next » 

Revision 1f9ccef9

Added by koszko about 1 year ago

restore compatibility with IceCat 60

This commit also fixes the --driver option to configure script.

View differences:

common/entities.js
117 117
#EXPORT get_used_files AS get_files
118 118

  
119 119
/*
120
 * Regex to parse URIs like:
120
 * Function to parse URIs like:
121 121
 *     https://hydrilla.koszko.org/schemas/api_mapping_description-2.schema.json
122 122
 */
123
const name_base_re    = "(?<name_base>[^/]*)";
124
const major_number_re = "(?<major>[1-9][0-9]*)";
123
const name_base_re    = "([^/]*)";
124
const major_number_re = "([1-9][0-9]*)";
125 125
const minor_number_re = "(?:[1-9][0-9]*|0)";
126 126
const numbers_rest_re = `(?:\\.${minor_number_re})*`;
127
const version_re      = `(?<ver>${major_number_re}${numbers_rest_re})`;
127
const version_re      = `(${major_number_re}${numbers_rest_re})`;
128 128
const schema_name_re  = `${name_base_re}-${version_re}\\.schema\\.json`;
129 129

  
130
const haketilo_schema_name_regex = new RegExp(schema_name_re);
131
#EXPORT haketilo_schema_name_regex
130
const schema_name_regex = new RegExp(schema_name_re);
131

  
132
const schema_name_parts = ["full", "name_base", "version", "major"];
133

  
134
function parse_schema_uri(uri) {
135
    const match = schema_name_regex.exec(uri);
136
    if (!match)
137
	return match;
138

  
139
    const result = {};
140

  
141
    for (let i = 0; i < schema_name_parts.length; i++)
142
	result[schema_name_parts[i]] = match[i];
143

  
144
    return result
145
}
146
#EXPORT parse_schema_uri
132 147

  
133 148
/* Extract the number that indicates entity's compatibility mode. */
134 149
function get_schema_major_version(instance) {
135
    const match = haketilo_schema_name_regex.exec(instance.$schema);
136

  
137
    return parseInt(match.groups.major);
150
    return parseInt(parse_schema_uri(instance.$schema).major);
138 151
}
139 152
#EXPORT get_schema_major_version
140 153

  

Also available in: Unified diff