{"version":3,"file":"getRepositoryName.cjs","names":["PrismicError"],"sources":["../src/getRepositoryName.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\n\n/**\n * Get a Prismic repository's name from its standard Prismic Document API or GraphQL endpoint.\n *\n * @param repositoryEndpoint - Prismic Document API endpoint for the repository.\n * @returns The Prismic repository's name.\n * @throws {@link Error} Thrown if an invalid Prismic Document API endpoint is\n * provided.\n */\nexport const getRepositoryName = (repositoryEndpoint: string): string => {\n\ttry {\n\t\tconst hostname = new URL(repositoryEndpoint).hostname\n\n\t\tif (\n\t\t\thostname.endsWith(\"prismic.io\") || // Production\n\t\t\thostname.endsWith(\"wroom.io\") || // Staging\n\t\t\thostname.endsWith(\"dev-tools-wroom.com\") || // Dev-Tools\n\t\t\thostname.endsWith(\"marketing-tools-wroom.com\") || // Marketing-Tools\n\t\t\thostname.endsWith(\"platform-wroom.com\") || // Platform\n\t\t\thostname.endsWith(\"wroom.test\") // Dev\n\t\t) {\n\t\t\treturn hostname.split(\".\")[0]\n\t\t}\n\t} catch {}\n\n\tthrow new PrismicError(\n\t\t`An invalid Prismic Document API endpoint was provided: ${repositoryEndpoint}`,\n\t\tundefined,\n\t\tundefined,\n\t)\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qBAAqB,uBAAuC;AACxE,KAAI;EACH,MAAM,WAAW,IAAI,IAAI,mBAAmB,CAAC;AAE7C,MACC,SAAS,SAAS,aAAa,IAC/B,SAAS,SAAS,WAAW,IAC7B,SAAS,SAAS,sBAAsB,IACxC,SAAS,SAAS,4BAA4B,IAC9C,SAAS,SAAS,qBAAqB,IACvC,SAAS,SAAS,aAAa,CAE/B,QAAO,SAAS,MAAM,IAAI,CAAC;SAErB;AAER,OAAM,IAAIA,eAAAA,aACT,0DAA0D,sBAC1D,KAAA,GACA,KAAA,EACA"}