From 819c6e802b8a383fc13288908aaf64c080bd82cc Mon Sep 17 00:00:00 2001 From: lazynina Date: Mon, 21 Jun 2021 16:10:34 -0700 Subject: [PATCH 1/6] hold current progress for twitch embeds --- .../feed-create-post.component.ts | 2 +- .../embed-url-parser-service.ts | 81 ++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/app/feed/feed-create-post/feed-create-post.component.ts b/src/app/feed/feed-create-post/feed-create-post.component.ts index 282119e41..e7eaa3336 100644 --- a/src/app/feed/feed-create-post/feed-create-post.component.ts +++ b/src/app/feed/feed-create-post/feed-create-post.component.ts @@ -124,7 +124,7 @@ export class FeedCreatePostComponent implements OnInit { setEmbedURL() { EmbedUrlParserService.getEmbedURL(this.backendApi, this.globalVars, this.embedURL).subscribe( (res) => (this.constructedEmbedURL = res) - ); + ).add(() => console.log(this.constructedEmbedURL)); } submitPost() { diff --git a/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts b/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts index 4bd2abc90..665822b84 100644 --- a/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts +++ b/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts @@ -76,6 +76,52 @@ export class EmbedUrlParserService { : ""; } + static twitchParser(url: string): string | boolean { + const regExp = /^.*((player\.|clips\.)?twitch\.tv)\/(videos\/(\d{8,12})|\?video=(\d{8,12})|\?channel=([A-Za-z0-9_]{1,30})|collections\/([A-Za-z0-9]{10,20})|\?collection=([A-Za-z0-9]{10,20})|embed\?clip=([A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30})|([A-Za-z0-9_]{1,30}(\/clip\/([A-Za-z0-9_]{1,50}-[A-Za-z0-9_]{1,30}))?)).*/; + // const regExp = /^.*((player\.|clips\.)?twitch\.tv)\/(videos\/(\d{8,12})|\?video=(\d{8,12})|\?channel=([A-Za-z0-9_]{1,30})|(embed\?clip=([A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30}))|([A-Za-z0-9_]{1,30}(\?|$))|([A-Za-z0-9_]{1,30}(\/clip\/([A-Za-z0-9_]{1,50}-[A-Za-z0-9_]{1,30}))?)).*/; + const match = url.match(regExp); + if (match && match[3]) { + // https://www.twitch.tv/videos/1052085725 + if (match[3].startsWith("videos") && match[4]) { + return `player.twitch.tv/?video=${match[4]}`; + } + // https://player.twitch.tv/?video=1052085725&parent=www.example.com + if (match[3].startsWith("?video=") && match[5]) { + return `player.twitch.tv/?video=${match[5]}`; + } + // https://player.twitch.tv/?channel=kindafunnygames&parent=www.example.com + if (match[3].startsWith("?channel=") && match[6]) { + return `player.twitch.tv/?channel=${match[6]}`; + } + // https://www.twitch.tv/kindafunnygames + if (match[3] && match[10] && match[3] === match[10]) { + return `player.twitch.tv/?channel=${match[10]}`; + } + // https://www.twitch.tv/silfy_star/clip/BadPunchyMangetoutPlanking-rrZQEE5Vib02ZvG7 + if (match[11] && match[12]) { + return `clips.twitch.tv/embed?clip=${match[12]}`; + } + // https://clips.twitch.tv/embed?clip=BadPunchyMangetoutPlanking-rrZQEE5Vib02ZvG7&parent=www.example.com + if (match[9]) { + return `clips.twitch.tv/embed?clip=${match[9]}`; + } + // https://www.twitch.tv/collections/88mjamlm4xT7nQ?filter=collections + if (match[7]) { + return `player.twitch.tv/?collection=${match[7]}`; + } + // https://player.twitch.tv/?collection=88mjamlm4xT7nQ&video=529592821&parent=www.example.com + if (match[8]) { + return `player.twitch.tv/?collection=${match[8]}`; + } + } + return false; + } + + static constructTwitchEmbedURL(url: URL): string { + const twitchParsed = this.twitchParser(url.toString()); + return twitchParsed ? `https://${twitchParsed}` : ""; + } + static extractTikTokVideoID(fullTikTokURL: string): string | boolean { const regExp = /^.*((tiktok\.com\/)(v\/)|(@[A-Za-z0-9_-]{2,24}\/video\/)|(embed\/v2\/))(\d{0,30}).*/; const match = fullTikTokURL.match(regExp); @@ -157,6 +203,11 @@ export class EmbedUrlParserService { if (this.isSoundCloudFromURL(url)) { return of(this.constructSoundCloudEmbedURL(url)); } + if (this.isTwitchFromURL(url)) { + return of(this.constructTwitchEmbedURL(url)).pipe( + map((embedURL) => (embedURL ? embedURL + `&parent=${location.hostname}` : "")) + ); + } return of(""); } @@ -244,6 +295,20 @@ export class EmbedUrlParserService { return pattern.test(url.hostname); } + static isTwitchLink(link: string): boolean { + try { + const url = new URL(link); + return this.isTwitchFromURL(url); + } catch (e) { + return false; + } + } + + static isTwitchFromURL(url: URL): boolean { + const pattern = /\btwitch\.tv$/; + return pattern.test(url.hostname); + } + static isValidVimeoEmbedURL(link: string): boolean { const regExp = /(https:\/\/player\.vimeo\.com\/video\/(\d{0,15}))$/; return !!link.match(regExp); @@ -274,6 +339,18 @@ export class EmbedUrlParserService { return !!link.match(regExp); } + static isValidTwitchEmbedURL(link: string): boolean { + const regExp = /(https:\/\/(player|clips)\.twitch\.tv\/(\?channel=[A-Za-z0-9_]{1,30}|\?video=\d{8,12}|embed\?clip=[A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30}|\?collection=[A-Za-z0-9]{10,20}))$/; + return !!link.match(regExp); + } + + static isValidTwitchEmbedURLWithParent(link: string): boolean { + const regExp = new RegExp( + `https:\/\/(player|clips)\.twitch\.tv\/(\\?channel\=[A-Za-z0-9_]{1,30}|\\?video=\\d{8,12}|embed\\?clip=[A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30}|\\?collection=[A-Za-z0-9]{10,20})\&parent=${location.hostname}$` + ); + return !!link.match(regExp); + } + static isValidEmbedURL(link: string): boolean { if (link) { return ( @@ -282,7 +359,9 @@ export class EmbedUrlParserService { this.isValidTiktokEmbedURL(link) || this.isValidGiphyEmbedURL(link) || this.isValidSpotifyEmbedURL(link) || - this.isValidSoundCloudEmbedURL(link) + this.isValidSoundCloudEmbedURL(link) || + this.isValidTwitchEmbedURL(link) || + this.isValidTwitchEmbedURLWithParent(link) ); } return false; From 2abaa2f6a40613810a98ce7ffc6de8e271bfa37a Mon Sep 17 00:00:00 2001 From: lazynina Date: Mon, 21 Jun 2021 16:32:55 -0700 Subject: [PATCH 2/6] add twitch to caddyfile --- Caddyfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Caddyfile b/Caddyfile index b73d9772c..f95013786 100644 --- a/Caddyfile +++ b/Caddyfile @@ -68,5 +68,7 @@ header @html Content-Security-Policy " https://giphy.com https://open.spotify.com https://w.soundcloud.com + https://player.twitch.com + https://clips.twitch.com pay.testwyre.com pay.sendwyre.com;" From 151a40534ac3fc6d43d5bfa1de25b5bd1dfce18b Mon Sep 17 00:00:00 2001 From: lazynina Date: Mon, 21 Jun 2021 18:14:54 -0700 Subject: [PATCH 3/6] add more cases to regex to handle collections and clips for twitch, add tests, close embed url input after submitting post --- .../feed-create-post.component.ts | 3 +- .../embed-url-parser-service.spec.ts | 57 +++++++++++++++++++ .../embed-url-parser-service.ts | 35 ++++++------ 3 files changed, 76 insertions(+), 19 deletions(-) diff --git a/src/app/feed/feed-create-post/feed-create-post.component.ts b/src/app/feed/feed-create-post/feed-create-post.component.ts index e7eaa3336..cd4546465 100644 --- a/src/app/feed/feed-create-post/feed-create-post.component.ts +++ b/src/app/feed/feed-create-post/feed-create-post.component.ts @@ -124,7 +124,7 @@ export class FeedCreatePostComponent implements OnInit { setEmbedURL() { EmbedUrlParserService.getEmbedURL(this.backendApi, this.globalVars, this.embedURL).subscribe( (res) => (this.constructedEmbedURL = res) - ).add(() => console.log(this.constructedEmbedURL)); + ); } submitPost() { @@ -183,6 +183,7 @@ export class FeedCreatePostComponent implements OnInit { this.postImageSrc = null; this.embedURL = ""; this.constructedEmbedURL = ""; + this.showEmbedURL = false; this.changeRef.detectChanges(); // Refresh the post page. diff --git a/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts b/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts index a40f6cf21..297883241 100644 --- a/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts +++ b/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts @@ -98,6 +98,25 @@ describe("EmbedUrlParserService", () => { return `https://w.soundcloud.com/player/?url=${url}?hide_related=true&show_comments=false`; }); + const twitchVideoID = "1234567890"; + const twitchChannelID = "chann3lId"; + const twitchClipID = "SomeClipId-123iuMA32-m0"; + const twitchCollectionID = "M123k88lskjqi"; + + const validTwitchURLs = [ + `https://www.twitch.tv/${twitchChannelID}`, + `https://www.twitch.tv/videos/${twitchVideoID}`, + `https://www.twitch.tv/collections/${twitchCollectionID}`, + `https://www.twitch.tv/${twitchChannelID}/clip/${twitchClipID}`, + ]; + + const validTwitchEmbedURLs = [ + `https://player.twitch.tv/?channel=${twitchChannelID}`, + `https://player.twitch.tv/?video=${twitchVideoID}`, + `https://player.twitch.tv/?collection=${twitchCollectionID}`, + `https://clips.twitch.tv/embed?clip=${twitchClipID}`, + ]; + const invalidURLs = [ "https://google.com", "facebook.com", @@ -109,6 +128,10 @@ describe("EmbedUrlParserService", () => { `https://giphy.com/gifs/abc-def-${giphyID}-;`, `https://open.notspotify.com/embed/track/${spotifyID}-?;`, `https://w.soundcloud.com/player/?hide_related=true&show_comments=false`, + `https://player.twitch.tv/?video=aaa${twitchVideoID}`, + `https://player.twitch.tv/?channel=${twitchChannelID}`, + `https://clips.twitch.tv/embed?clip=${twitchClipID}`, + `https://player.twitch.tv/?collections=!@#&*!)@#${twitchCollectionID}`, ]; it("parses youtube URLs from user input correctly and only validates embed urls", () => { @@ -228,6 +251,40 @@ describe("EmbedUrlParserService", () => { } }); + it("parses Twitch URLs from user input correctly and only validates embed urls", () => { + for (let i = 0; i < validTwitchURLs.length; i++) { + const link = validTwitchURLs[i]; + const embedLink = validTwitchEmbedURLs[i]; + expect(EmbedUrlParserService.isTwitchLink(link)).toBeTruthy(); + const embedURL = EmbedUrlParserService.constructTwitchEmbedURL(new URL(link)); + expect(embedURL).toEqual(embedLink); + expect(EmbedUrlParserService.isValidEmbedURL(embedURL)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURL(embedURL)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(embedURL)).toBeFalsy(); + expect(EmbedUrlParserService.isValidEmbedURL(link)).toBeFalsy(); + + EmbedUrlParserService.getEmbedURL(backendApiService, globalVarsService, link).subscribe((res) => { + expect(res).toEqual(embedLink + `&parent=${location.hostname}`); + expect(EmbedUrlParserService.isValidEmbedURL(res)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(res)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURL(res)).toBeFalsy(); + }); + + expect(EmbedUrlParserService.isTwitchLink(embedLink)); + expect(EmbedUrlParserService.isValidEmbedURL(embedLink)); + const constructedEmbedUrl = EmbedUrlParserService.constructTwitchEmbedURL(new URL(embedLink)); + expect(EmbedUrlParserService.isValidTwitchEmbedURL(constructedEmbedUrl)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(constructedEmbedUrl)).toBeFalsy(); + + EmbedUrlParserService.getEmbedURL(backendApiService, globalVarsService, embedLink).subscribe((res) => { + expect(res).toEqual(embedLink + `&parent=${location.hostname}`); + expect(EmbedUrlParserService.isValidEmbedURL(res)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(res)).toBeTruthy(); + expect(EmbedUrlParserService.isValidTwitchEmbedURL(res)).toBeFalsy(); + }); + } + }); + it("invalid URLs return falsy values", async () => { for (const link of invalidURLs) { expect(EmbedUrlParserService.isValidEmbedURL(link)).toBeFalsy(); diff --git a/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts b/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts index 665822b84..da247a903 100644 --- a/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts +++ b/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts @@ -77,39 +77,38 @@ export class EmbedUrlParserService { } static twitchParser(url: string): string | boolean { - const regExp = /^.*((player\.|clips\.)?twitch\.tv)\/(videos\/(\d{8,12})|\?video=(\d{8,12})|\?channel=([A-Za-z0-9_]{1,30})|collections\/([A-Za-z0-9]{10,20})|\?collection=([A-Za-z0-9]{10,20})|embed\?clip=([A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30})|([A-Za-z0-9_]{1,30}(\/clip\/([A-Za-z0-9_]{1,50}-[A-Za-z0-9_]{1,30}))?)).*/; - // const regExp = /^.*((player\.|clips\.)?twitch\.tv)\/(videos\/(\d{8,12})|\?video=(\d{8,12})|\?channel=([A-Za-z0-9_]{1,30})|(embed\?clip=([A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30}))|([A-Za-z0-9_]{1,30}(\?|$))|([A-Za-z0-9_]{1,30}(\/clip\/([A-Za-z0-9_]{1,50}-[A-Za-z0-9_]{1,30}))?)).*/; + const regExp = /^.*((player\.|clips\.)?twitch\.tv)\/(videos\/(\d{8,12})|\?video=(\d{8,12})|\?channel=([A-Za-z0-9_]{1,30})|collections\/([A-Za-z0-9]{10,20})|\?collection=([A-Za-z0-9]{10,20}(&video=\d{8,12})?)|embed\?clip=([A-Za-z0-9_-]{1,80})|([A-Za-z0-9_]{1,30}(\/clip\/([A-Za-z0-9_-]{1,80}))?)).*/; const match = url.match(regExp); if (match && match[3]) { - // https://www.twitch.tv/videos/1052085725 + // https://www.twitch.tv/videos/1234567890 if (match[3].startsWith("videos") && match[4]) { return `player.twitch.tv/?video=${match[4]}`; } - // https://player.twitch.tv/?video=1052085725&parent=www.example.com + // https://player.twitch.tv/?video=1234567890&parent=www.example.com if (match[3].startsWith("?video=") && match[5]) { return `player.twitch.tv/?video=${match[5]}`; } - // https://player.twitch.tv/?channel=kindafunnygames&parent=www.example.com + // https://player.twitch.tv/?channel=xxxyyy123&parent=www.example.com if (match[3].startsWith("?channel=") && match[6]) { return `player.twitch.tv/?channel=${match[6]}`; } - // https://www.twitch.tv/kindafunnygames - if (match[3] && match[10] && match[3] === match[10]) { - return `player.twitch.tv/?channel=${match[10]}`; + // https://www.twitch.tv/xxxyyy123 + if (match[3] && match[11] && match[3] === match[11] && !match[12] && !match[13]) { + return `player.twitch.tv/?channel=${match[11]}`; } - // https://www.twitch.tv/silfy_star/clip/BadPunchyMangetoutPlanking-rrZQEE5Vib02ZvG7 - if (match[11] && match[12]) { - return `clips.twitch.tv/embed?clip=${match[12]}`; + // https://www.twitch.tv/xxyy_1234m/clip/AbCD123JMn-rrMMSj1239G7 + if (match[12] && match[13]) { + return `clips.twitch.tv/embed?clip=${match[13]}`; } - // https://clips.twitch.tv/embed?clip=BadPunchyMangetoutPlanking-rrZQEE5Vib02ZvG7&parent=www.example.com - if (match[9]) { - return `clips.twitch.tv/embed?clip=${match[9]}`; + // https://clips.twitch.tv/embed?clip=AbCD123JMn-rrMMSj1239G7&parent=www.example.com + if (match[10]) { + return `clips.twitch.tv/embed?clip=${match[10]}`; } - // https://www.twitch.tv/collections/88mjamlm4xT7nQ?filter=collections + // https://www.twitch.tv/collections/11jaabbcc2yM989x?filter=collections if (match[7]) { return `player.twitch.tv/?collection=${match[7]}`; } - // https://player.twitch.tv/?collection=88mjamlm4xT7nQ&video=529592821&parent=www.example.com + // https://player.twitch.tv/?collection=11jaabbcc2yM989x&video=1234567890&parent=www.example.com if (match[8]) { return `player.twitch.tv/?collection=${match[8]}`; } @@ -340,13 +339,13 @@ export class EmbedUrlParserService { } static isValidTwitchEmbedURL(link: string): boolean { - const regExp = /(https:\/\/(player|clips)\.twitch\.tv\/(\?channel=[A-Za-z0-9_]{1,30}|\?video=\d{8,12}|embed\?clip=[A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30}|\?collection=[A-Za-z0-9]{10,20}))$/; + const regExp = /(https:\/\/(player|clips)\.twitch\.tv\/(\?channel=[A-Za-z0-9_]{1,30}|\?video=\d{8,12}|embed\?clip=[A-Za-z0-9_-]{1,80}|\?collection=[A-Za-z0-9]{10,20}(&video=\d{8,12})?))$/; return !!link.match(regExp); } static isValidTwitchEmbedURLWithParent(link: string): boolean { const regExp = new RegExp( - `https:\/\/(player|clips)\.twitch\.tv\/(\\?channel\=[A-Za-z0-9_]{1,30}|\\?video=\\d{8,12}|embed\\?clip=[A-Za-z0-9_]{1,50}-[A-Za-z0-9]{1,30}|\\?collection=[A-Za-z0-9]{10,20})\&parent=${location.hostname}$` + `https:\/\/(player|clips)\.twitch\.tv\/(\\?channel\=[A-Za-z0-9_]{1,30}|\\?video=\\d{8,12}|embed\\?clip=[A-Za-z0-9_-]{1,80}|\\?collection=[A-Za-z0-9]{10,20}(\&video=\\d{8,12})\?)\&parent=${location.hostname}$` ); return !!link.match(regExp); } From 43845cd2ff7ed4595322f745086226b02b2d8d76 Mon Sep 17 00:00:00 2001 From: lazynina Date: Wed, 29 Sep 2021 11:40:45 -0400 Subject: [PATCH 4/6] fix caddyfile --- Caddyfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Caddyfile b/Caddyfile index 02c74fa7a..bd3e9dcc1 100644 --- a/Caddyfile +++ b/Caddyfile @@ -72,8 +72,8 @@ header @html Content-Security-Policy " https://giphy.com https://open.spotify.com https://w.soundcloud.com - https://player.twitch.com - https://clips.twitch.com + https://player.twitch.tv + https://clips.twitch.tv pay.testwyre.com pay.sendwyre.com; frame-ancestors 'self';" From 5de4fe15f806b740c2028185547dcaceb1f6666d Mon Sep 17 00:00:00 2001 From: lazynina Date: Wed, 29 Sep 2021 12:02:59 -0400 Subject: [PATCH 5/6] prevent autoplay on twitch embeds --- .../creator-profile-nfts.component.spec.ts | 2 +- .../embed-url-parser-service/embed-url-parser-service.spec.ts | 4 ++-- .../embed-url-parser-service/embed-url-parser-service.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/creator-profile-page/creator-profile-nfts/creator-profile-nfts.component.spec.ts b/src/app/creator-profile-page/creator-profile-nfts/creator-profile-nfts.component.spec.ts index 806db801c..32aa206e0 100644 --- a/src/app/creator-profile-page/creator-profile-nfts/creator-profile-nfts.component.spec.ts +++ b/src/app/creator-profile-page/creator-profile-nfts/creator-profile-nfts.component.spec.ts @@ -1,6 +1,6 @@ import { async, ComponentFixture, TestBed } from "@angular/core/testing"; -import { CreatorProfileNftsComponent } from "./creator-profile-posts.component"; +import { CreatorProfileNftsComponent } from "./creator-profile-nfts.component"; describe("CreatorProfilePostsComponent", () => { let component: CreatorProfileNftsComponent; diff --git a/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts b/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts index 297883241..08443b83a 100644 --- a/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts +++ b/src/lib/services/embed-url-parser-service/embed-url-parser-service.spec.ts @@ -264,7 +264,7 @@ describe("EmbedUrlParserService", () => { expect(EmbedUrlParserService.isValidEmbedURL(link)).toBeFalsy(); EmbedUrlParserService.getEmbedURL(backendApiService, globalVarsService, link).subscribe((res) => { - expect(res).toEqual(embedLink + `&parent=${location.hostname}`); + expect(res).toEqual(embedLink + `&autoplay=false&parent=${location.hostname}`); expect(EmbedUrlParserService.isValidEmbedURL(res)).toBeTruthy(); expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(res)).toBeTruthy(); expect(EmbedUrlParserService.isValidTwitchEmbedURL(res)).toBeFalsy(); @@ -277,7 +277,7 @@ describe("EmbedUrlParserService", () => { expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(constructedEmbedUrl)).toBeFalsy(); EmbedUrlParserService.getEmbedURL(backendApiService, globalVarsService, embedLink).subscribe((res) => { - expect(res).toEqual(embedLink + `&parent=${location.hostname}`); + expect(res).toEqual(embedLink + `&autoplay=false&parent=${location.hostname}`); expect(EmbedUrlParserService.isValidEmbedURL(res)).toBeTruthy(); expect(EmbedUrlParserService.isValidTwitchEmbedURLWithParent(res)).toBeTruthy(); expect(EmbedUrlParserService.isValidTwitchEmbedURL(res)).toBeFalsy(); diff --git a/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts b/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts index 1e692088b..f02c6fe17 100644 --- a/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts +++ b/src/lib/services/embed-url-parser-service/embed-url-parser-service.ts @@ -204,7 +204,7 @@ export class EmbedUrlParserService { } if (this.isTwitchFromURL(url)) { return of(this.constructTwitchEmbedURL(url)).pipe( - map((embedURL) => (embedURL ? embedURL + `&parent=${location.hostname}` : "")) + map((embedURL) => (embedURL ? embedURL + `&autoplay=false&parent=${location.hostname}` : "")) ); } return of(""); @@ -345,7 +345,7 @@ export class EmbedUrlParserService { static isValidTwitchEmbedURLWithParent(link: string): boolean { const regExp = new RegExp( - `https:\/\/(player|clips)\.twitch\.tv\/(\\?channel\=[A-Za-z0-9_]{1,30}|\\?video=\\d{8,12}|embed\\?clip=[A-Za-z0-9_-]{1,80}|\\?collection=[A-Za-z0-9]{10,20}(\&video=\\d{8,12})\?)\&parent=${location.hostname}$` + `https:\/\/(player|clips)\.twitch\.tv\/(\\?channel\=[A-Za-z0-9_]{1,30}|\\?video=\\d{8,12}|embed\\?clip=[A-Za-z0-9_-]{1,80}|\\?collection=[A-Za-z0-9]{10,20}(\&video=\\d{8,12})\?)\&autoplay=false\&parent=${location.hostname}$` ); return !!link.match(regExp); } From ef4836b977631940fe9cc5845c3ab028f08956d3 Mon Sep 17 00:00:00 2001 From: lazynina Date: Sun, 10 Oct 2021 01:11:52 -0400 Subject: [PATCH 6/6] add Twitch to placeholder text for the embed input box, decrease font-size --- src/app/feed/feed-create-post/feed-create-post.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/feed/feed-create-post/feed-create-post.component.html b/src/app/feed/feed-create-post/feed-create-post.component.html index 339adfe67..1290d8822 100644 --- a/src/app/feed/feed-create-post/feed-create-post.component.html +++ b/src/app/feed/feed-create-post/feed-create-post.component.html @@ -84,13 +84,13 @@ -
+