{"version":3,"file":"url.mjs","sources":["../../../lib/upload/utils/url.ts"],"sourcesContent":["/*\n * SPDX-License-Identifier: AGPL-3.0-or-later\n * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors\n */\n\nimport { encodePath } from '@nextcloud/paths'\n\n/**\n * Concatenates a base URL (allowing protocol) and a path segment\n *\n * @param base - the base URL, e.g. \"https://example.com/dav\"\n * @param path - the path segment to concatenate, e.g. \"test.txt\"\n */\nexport function concatUrl(base: string, path: string): string {\n\tif (base.endsWith('/')) {\n\t\tbase = base.slice(0, -1)\n\t}\n\tif (path.startsWith('/')) {\n\t\tpath = path.slice(1)\n\t}\n\treturn `${base}/${path}`\n}\n\n/**\n * URL encode the path of a decoded URL, leaving a potential origin untouched.\n * This must be used whenever a source is used for a request (as URL or `Destination` header).\n *\n * @param url - The decoded URL, either absolute (\"https://example.com/dav/a b.txt\") or a path (\"/dav/a b.txt\")\n */\nexport function encodeUrl(url: string): string {\n\t// Only the path must be encoded, so keep a potential origin as-is\n\tconst origin = url.match(/^[a-z][a-z\\d+\\-.]*:\\/\\/[^/]*/i)?.[0] ?? ''\n\treturn origin + encodePath(url.slice(origin.length))\n}\n"],"names":[],"mappings":";AAaO,SAAS,UAAU,MAAc,MAAsB;AAC7D,MAAI,KAAK,SAAS,GAAG,GAAG;AACvB,WAAO,KAAK,MAAM,GAAG,EAAE;AAAA,EACxB;AACA,MAAI,KAAK,WAAW,GAAG,GAAG;AACzB,WAAO,KAAK,MAAM,CAAC;AAAA,EACpB;AACA,SAAO,GAAG,IAAI,IAAI,IAAI;AACvB;AAQO,SAAS,UAAU,KAAqB;AAE9C,QAAM,SAAS,IAAI,MAAM,+BAA+B,IAAI,CAAC,KAAK;AAClE,SAAO,SAAS,WAAW,IAAI,MAAM,OAAO,MAAM,CAAC;AACpD;"}