frontend/.pnpm-store/v3/files/6b/bbdb3c4d3a7b0975bac08e36ed3ed2e1143a4ba9fe6ac286ad22e6c3010a305f7329e0a719fc7d8e9089affb73b6efa8d7eeb308873a7c272d6a41820e0b8f

36 lines
725 B
Plaintext

export default function newGithubReleaseUrl(options = {}) {
let repoUrl;
if (options.repoUrl) {
repoUrl = options.repoUrl;
} else if (options.user && options.repo) {
repoUrl = `https://github.com/${options.user}/${options.repo}`;
} else {
throw new Error('You need to specify either the `repoUrl` option or both the `user` and `repo` options');
}
const url = new URL(`${repoUrl}/releases/new`);
const types = [
'tag',
'target',
'title',
'body',
'isPrerelease',
];
for (let type of types) {
const value = options[type];
if (value === undefined) {
continue;
}
if (type === 'isPrerelease') {
type = 'prerelease';
}
url.searchParams.set(type, value);
}
return url.toString();
}