Sha256: cc206f5243d64a1bdd1dd4e8a47f8d9ab611202d7bdc39560421301a44ba122d

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

/*global define*/
define(['Core/defined', 'Core/DeveloperError', 'ThirdParty/Uri'], function(
        defined,
        DeveloperError,
        Uri) {
    "use strict";

    /**
     * Given a URI, returns the last segment of the URI, removing any path or query information.
     * @exports getFilenameFromUri
     *
     * @param {String} uri The Uri.
     * @returns {String} The last segment of the Uri.
     *
     * @exception {DeveloperError} uri is required.
     *
     * @example
     * //fileName will be"simple.czml";
     * var fileName = Cesium.getFilenameFromUri('/Gallery/simple.czml?value=true&example=false');
     */
    var getFilenameFromUri = function(uri) {
        //>>includeStart('debug', pragmas.debug);
        if (!defined(uri)) {
            throw new DeveloperError('uri is required.');
        }
        //>>includeEnd('debug');

        var uriObject = new Uri(uri);
        uriObject.normalize();
        var path = uriObject.path;
        var index = path.lastIndexOf('/');
        if (index !== -1) {
            path = path.substr(index + 1);
        }
        return path;
    };

    return getFilenameFromUri;
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cesium-0.25.0 app/assets/javascripts/Core/getFilenameFromUri.js