Fix relative links in video description

pull/2737/head
Chocobozzz 2020-05-06 14:21:10 +02:00
parent 1df8a4d79a
commit d4eea02801
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 21 additions and 22 deletions

View File

@ -10,7 +10,8 @@ export class TimestampRouteTransformerDirective {
public onClick ($event: Event) {
const target = $event.target as HTMLLinkElement
if (target.hasAttribute('href')) {
if (target.hasAttribute('href') !== true) return
const ngxLink = document.createElement('a')
ngxLink.href = target.getAttribute('href')
@ -18,7 +19,8 @@ export class TimestampRouteTransformerDirective {
if (ngxLink.host !== window.location.host) return
const ngxLinkParams = new URLSearchParams(ngxLink.search)
if (ngxLinkParams.has('start')) {
if (ngxLinkParams.has('start') !== true) return
const separators = ['h', 'm', 's']
const start = ngxLinkParams
.get('start')
@ -29,12 +31,9 @@ export class TimestampRouteTransformerDirective {
return parseInt(t, 10)
})
.reduce((acc, t) => acc + t)
this.timestampClicked.emit(start)
}
$event.preventDefault()
}
return
}
}