@bioneisme/greenfield-cli
Version:
CLI For BNB Greenfield SDK
20 lines (19 loc) • 773 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseBucketAndObject = void 0;
function parseBucketAndObject(urlPath) {
if (urlPath.includes("gnfd://")) {
urlPath = urlPath.substring("gnfd://".length);
}
else {
console.error(`URL is not in the correct format (gnfd://). Unable to parse bucket name and object name. ${urlPath}`);
}
const index = urlPath.indexOf("/");
if (index <= -1) {
throw new Error("URL is not in the correct format. Unable to parse bucket name and object name.");
}
const bucketName = urlPath.substring(0, index);
const objectName = urlPath.substring(index + 1);
return [bucketName, objectName];
}
exports.parseBucketAndObject = parseBucketAndObject;