Skip to content

Commit

Permalink
youtube allow
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-bao committed Apr 4, 2024
1 parent 4eb216a commit fe8aa17
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions render/src/test/test.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export function mockFetch(urlList:MapOf<object>):void{
})
}

declare module globalThis {
let NestedMenuGlobal:object;
}
export function initDom():void{
globalThis.NestedMenuGlobal = {}
document.body.innerHTML = `<div id="content"></div>`
window.location.search = '?dashboardItemId=WidgetId'
}
1 change: 1 addition & 0 deletions render/src/test/widget/3.sanitizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const testCases:string[][] = [
['<script>console.log()</script>content','content'],
['<script>1</script>middle<script>2</script>',''],
['<iframe src="xxx"/>',''],
['<iframe src="https://www.youtube.com/embed/zduSFxRajkE?si=U11mG5dlUVzskN1O"/>','<iframe src="https://www.youtube.com/embed/zduSFxRajkE?si=U11mG5dlUVzskN1O"/>']
]

test(`3 > Sanitizer Test`, ()=>{
Expand Down
11 changes: 10 additions & 1 deletion shared/sanitizeContent.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
const badTags = ['script','applet','iframe','link']
const badTags = ['script','applet','link']
// const videoProviders = ['youtube.','youtu.be','yt.be','tiktok.com','vimeo.com', 'brightcove.com', 'brightcove.net', 'facebook.','fb.com','fb.me']

// function isVideoProvider(tag:string):boolean{
// return videoProviders.some(domain=>tag.includes(domain))
// }

export function sanitizeContent(input:string):string{
// <script.+/script> or <script.+/>
badTags.forEach(tag=>input = input.replace(new RegExp(`<${tag}.+\/(${tag}|)>`),''))
// input = input.replace(/<iframe.+\/>/,function (tag:string){
// if (isVideoProvider(tag)) return tag
// else return ''
// })
return input
}
10 changes: 10 additions & 0 deletions shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2016",
"module": "ESNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}

0 comments on commit fe8aa17

Please # to comment.