MCPcopy
hub / github.com/CapSoftware/Cap / consentPageUrl

Function consentPageUrl

packages/web-backend/src/Extension/Http.ts:79–94  ·  view source on GitHub ↗
(
	requestUrl: string,
	params: { redirectUri: string; state: Option.Option<string> },
)

Source from the content-addressed store, hash-verified

77// current endpoint path, which keeps it correct under whatever prefix the
78// host app mounts the API.
79const consentPageUrl = (
80 requestUrl: string,
81 params: { redirectUri: string; state: Option.Option<string> },
82) => {
83 const currentUrl = new URL(requestUrl, serverEnv().WEB_URL);
84 const startPath = Extension.ExtensionApiPaths.startAuth.slice(
85 Extension.ExtensionApiPaths.startAuth.lastIndexOf("/") + 1,
86 );
87 const startUrl = new URL(startPath, currentUrl);
88 startUrl.search = "";
89 startUrl.searchParams.set("redirectUri", params.redirectUri);
90 if (Option.isSome(params.state)) {
91 startUrl.searchParams.set("state", params.state.value);
92 }
93 return startUrl;
94};
95
96const escapeHtml = (value: string) =>
97 value

Callers 1

Http.tsFile · 0.85

Calls 1

serverEnvFunction · 0.90

Tested by

no test coverage detected