Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 229x 1x 228x 228x 228x 228x 228x 218x 228x | import Uri from "urijs";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
/**
* Given a URI, returns the last segment of the URI, removing any path or query information.
* @function getFilenameFromUri
*
* @param {string} uri The Uri.
* @returns {string} The last segment of the Uri.
*
* @example
* //fileName will be"simple.czml";
* const fileName = Cesium.getFilenameFromUri('/Gallery/simple.czml?value=true&example=false');
*/
function getFilenameFromUri(uri) {
//>>includeStart('debug', pragmas.debug);
if (!defined(uri)) {
throw new DeveloperError("uri is required.");
}
//>>includeEnd('debug');
const uriObject = new Uri(uri);
uriObject.normalize();
let path = uriObject.path();
const index = path.lastIndexOf("/");
if (index !== -1) {
path = path.substr(index + 1);
}
return path;
}
export default getFilenameFromUri;
|