Path: blob/main/components/gitpod-protocol/src/snapshot-url.ts
2498 views
/**1* Copyright (c) 2021 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56export interface SnapshotUrl {7bucketId: string;8fullPath: string;9filename: string;10}11export namespace SnapshotUrl {12export function parse(url: string): SnapshotUrl {13const parts = url.split("@");14if (parts.length !== 2) {15throw new Error(`cannot parse snapshot URL: ${url}`);16}17const [fullPath, bucketId] = parts;1819const pathParts = fullPath.split("/");20if (pathParts.length < 1) {21throw new Error(`cannot parse snapshot URL: ${url}`);22}23const filename = pathParts[pathParts.length - 1];24return { bucketId, fullPath, filename };25}26}272829