mirror of
https://github.com/outline/outline.git
synced 2025-12-30 23:40:46 -06:00
* Upgrade @typescript-eslint dependencies from v6.21.0 to v8.33.0 - Updated @typescript-eslint/eslint-plugin from ^6.21.0 to ^8.33.0 - Updated @typescript-eslint/parser from ^6.21.0 to ^8.33.0 - Tested linting functionality to ensure compatibility - This brings the latest TypeScript ESLint features and bug fixes * lint * tsc --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
26 lines
564 B
TypeScript
26 lines
564 B
TypeScript
import sharedEnv from "../env";
|
|
|
|
/**
|
|
* Parse the likely collection identifier from a given url.
|
|
*
|
|
* @param url The url to parse.
|
|
* @returns A collection identifier or undefined if not found.
|
|
*/
|
|
export default function parseCollectionSlug(url: string) {
|
|
let parsed;
|
|
|
|
if (url[0] === "/") {
|
|
url = `${sharedEnv.URL}${url}`;
|
|
}
|
|
|
|
try {
|
|
parsed = new URL(url).pathname;
|
|
} catch (_err) {
|
|
return;
|
|
}
|
|
|
|
const split = parsed.split("/");
|
|
const indexOfCollection = split.indexOf("collection");
|
|
return split[indexOfCollection + 1] ?? undefined;
|
|
}
|