Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support any conference #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function startWatching() {
case "update": {
const event = targetEvents.find((e) => e.id === p.id)!;
let { url, rule } = config.extractValidUrl(event)!;
if (rule.provider === "Google Meet") {
if (rule?.provider === "Google Meet") {
const tmp = new URL(url);
tmp.searchParams.set("authuser", user.email);
url = tmp.toString();
Expand All @@ -152,7 +152,7 @@ async function startWatching() {
case "add": {
const event = targetEvents.find((e) => e.id === p.id)!;
let { url, rule } = config.extractValidUrl(event)!;
if (rule.provider === "Google Meet") {
if (rule?.provider === "Google Meet") {
const tmp = new URL(url);
tmp.searchParams.set("authuser", user.email);
url = tmp.toString();
Expand Down
15 changes: 15 additions & 0 deletions src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ describe("Config", () => {
})
).toMatchObject({ rule: { provider: "Microsoft Teams" } });
});
it("can extract any conference video link", async () => {
const config = await loadConfig();
expect(
config.extractValidUrl({
conferenceData: {
entryPoints: [
{
entryPointType: "video",
uri: "https://example.com/",
},
],
},
})
).toMatchObject({ url: "https://example.com/", rule: null });
});

it.each([
// Without subdomains
Expand Down
7 changes: 6 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Config {
conferenceData?: any;
}): {
url: string;
rule: URLRule;
rule: URLRule | null;
} | null {
const urls: string[] = [
...getUrls(event.description ?? "", { requireSchemeOrWww: false }),
Expand All @@ -92,6 +92,11 @@ class Config {
url: videoEntryPoint[0].uri,
rule: matchedRule[0],
};
} else {
return {
url: videoEntryPoint[0].uri,
rule: null,
}
}
}
}
Expand Down