diff --git a/src/createClientFromOptions.ts b/src/createClientFromOptions.ts index 00e0592..ef98d4f 100644 --- a/src/createClientFromOptions.ts +++ b/src/createClientFromOptions.ts @@ -1,5 +1,5 @@ import nodeFetch from "node-fetch"; -import { Client, createClient, getEndpoint } from "@prismicio/client"; +import { Client, createClient } from "@prismicio/client"; import { PrismicPluginOptionsWithClient, @@ -28,14 +28,8 @@ export const createClientFromOptions = ( ): Client => { return "client" in options ? options.client - : createClient( - /** @see Regex101 expression: {@link https://regex101.com/r/GT2cl7/1} */ - /^(https?:)?\/\//gim.test(options.endpoint) - ? options.endpoint - : getEndpoint(options.endpoint), - { - fetch: nodeFetch, - ...options.clientConfig, - }, - ); + : createClient(options.endpoint, { + fetch: nodeFetch, + ...options.clientConfig, + }); }; diff --git a/test/createClientFromOptions.test.ts b/test/createClientFromOptions.test.ts index c979a1b..ff00d71 100644 --- a/test/createClientFromOptions.test.ts +++ b/test/createClientFromOptions.test.ts @@ -1,13 +1,25 @@ import test from "ava"; -import { Client } from "@prismicio/client"; +import { Client, createClient } from "@prismicio/client"; import { createClientFromOptions } from "../src"; const repositoryName = "createClientFromOptions-test-ts"; test("returns a Prismic client instance", (t) => { + t.true( + createClientFromOptions({ + client: createClient(repositoryName, { + fetch: async (url) => ({ status: 200, json: async () => url }), + }), + }) instanceof Client, + ); t.true( createClientFromOptions({ endpoint: repositoryName }) instanceof Client, ); + t.true( + createClientFromOptions({ + endpoint: `https://${repositoryName}.cdn.prismic.io/api/v2`, + }) instanceof Client, + ); });