All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.cldrjs.src.path.normalize.js Maven / Gradle / Ivy

The newest version!
define([
    "../util/array/is_array"
], function (arrayIsArray) {

    return function (path, attributes) {
        if (arrayIsArray(path)) {
            path = path.join("/");
        }
        if (typeof path !== "string") {
            throw new Error("invalid path \"" + path + "\"");
        }
        // 1: Ignore leading slash `/`
        // 2: Ignore leading `cldr/`
        path = path
            .replace(/^\//, "") /* 1 */
            .replace(/^cldr\//, "");
        /* 2 */

        // Replace {attribute}'s
        path = path.replace(/{[a-zA-Z]+}/g, function (name) {
            name = name.replace(/^{([^}]*)}$/, "$1");
            return attributes[name];
        });

        return path.split("/");
    };

});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy