Skip to content

Commit b701135

Browse files
committed
Refactor bug.ts.
Put URL parameters in another object/class and append them to the generated GitHub issue URL.
1 parent 58df1ff commit b701135

File tree

1 file changed

+22
-10
lines changed
  • sources/code/main/modules

1 file changed

+22
-10
lines changed

sources/code/main/modules/bug.ts

+22-10
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,36 @@ import { appInfo } from "../../common/modules/client";
1010
* Generates a link to new GitHub issue, based on `bug_report.md`
1111
* and current hardware / software configuration. This makes it
1212
* easy to aquire needed details (except screenshot, because of
13-
* the lack of the GitHub support to do that via the CDN or using
14-
* 'base64' images).
13+
* the lack of the GitHub support to do that ~~via the CDN or~~ using
14+
* `base64` encoded images).
1515
*
1616
* @property reason – A bug description (app failure reason).
1717
* @todo Parse (commented) values to be compatible with the template.
18+
* @todo Check GitHub API to actually use their CDN if possible.
1819
*/
1920
export async function createGithubIssue(reason?: string): Promise<void> {
2021
/** An URL to the new GitHub issue, based on YAML forms. */
2122
const githubIssueUrl = new URL(
22-
"https://github.com/"+appInfo.repository.name+"/issues/new"+
23-
"?assignees=SpacingBat3" + "&labels=bug" + "&template=bug.yml" +
24-
//'&platform='
25-
//'&architecture='
26-
"&electron_version=" + encodeURIComponent(process.versions.electron) +
27-
"&app_version=" + encodeURIComponent(app.getVersion()) +
28-
"&additional=" + encodeURIComponent("**Notice:** This issue was automatically generated by " + app.getName() + ".") +
29-
(reason ? "&description=" + encodeURIComponent(reason) : "")
23+
appInfo.repository.name+"/issues/new",
24+
"https://github.com"
3025
);
26+
/** A set of URL parameters appended to the {@link githubIssueUrl}. */
27+
const githubIssueUrlParams = new URLSearchParams({
28+
assignees: "SpacingBat3",
29+
labels: "bug",
30+
template: "bug.yml",
31+
//platform: "N/A",
32+
//architecture: "N/A",
33+
electron_version: process.versions.electron,
34+
app_version: app.getVersion(),
35+
additional: "**Notice:** This issue was automatically generated by " + app.getName() + "."
36+
});
37+
38+
githubIssueUrlParams
39+
.forEach((value,key) => githubIssueUrl.searchParams.append(key,value));
40+
41+
if(reason)
42+
githubIssueUrl.searchParams.append("description", reason);
3143

3244
/* Verify origin and open URL in default browser. */
3345

0 commit comments

Comments
 (0)