aboutsummaryrefslogtreecommitdiff
path: root/src/modules/protocol.js
blob: 1aeb7f9c628b34b4d2e7ad350da1515b882434b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const { app } = require("electron");

const win = require("../win");
const version = require("./version");

module.exports = async (argv) => {
	if (version.northstar() == "unknown")
		return;

	const args = argv || process.argv;

	for (const key of args) {
		if (key.startsWith("ror2mm://")) {
			let fragments = key.slice(9).split("/");
		
			if (fragments.length < 6)
				return;

			const ver = fragments[0];
			const term = fragments[1];
			const domain = fragments[2];
			const author = fragments[3];
			const package_name = fragments[4];
			const version = fragments[5];

			// There is only v1
			if (ver != "v1")
				continue;

			// No support for custom thunderstore instances
			if (domain != "thunderstore.io")
				continue;

			if (term == "install") {
				win().send("protocol-install-mod", [domain, author, package_name, version]);
			}
		}
	}
}