First upload version 0.0.1
This commit is contained in:
31
node_modules/@octokit/app/dist-src/get-installation-url.js
generated
vendored
Normal file
31
node_modules/@octokit/app/dist-src/get-installation-url.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
function getInstallationUrlFactory(app) {
|
||||
let installationUrlBasePromise;
|
||||
return async function getInstallationUrl(options = {}) {
|
||||
if (!installationUrlBasePromise) {
|
||||
installationUrlBasePromise = getInstallationUrlBase(app);
|
||||
}
|
||||
const installationUrlBase = await installationUrlBasePromise;
|
||||
const installationUrl = new URL(installationUrlBase);
|
||||
if (options.target_id !== void 0) {
|
||||
installationUrl.pathname += "/permissions";
|
||||
installationUrl.searchParams.append(
|
||||
"target_id",
|
||||
options.target_id.toFixed()
|
||||
);
|
||||
}
|
||||
if (options.state !== void 0) {
|
||||
installationUrl.searchParams.append("state", options.state);
|
||||
}
|
||||
return installationUrl.href;
|
||||
};
|
||||
}
|
||||
async function getInstallationUrlBase(app) {
|
||||
const { data: appInfo } = await app.octokit.request("GET /app");
|
||||
if (!appInfo) {
|
||||
throw new Error("[@octokit/app] unable to fetch metadata for app");
|
||||
}
|
||||
return `${appInfo.html_url}/installations/new`;
|
||||
}
|
||||
export {
|
||||
getInstallationUrlFactory
|
||||
};
|
||||
Reference in New Issue
Block a user