aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-06 14:21:10 +0200
committerChocobozzz <me@florianbigard.com>2020-05-06 14:21:10 +0200
commitd4eea028016092b36d9177616c9e6bb96df9abee (patch)
tree0365f11fd930bd74ac1d54e304a9dea07076a25e /client
parent1df8a4d79a491d2ad5bdd9329f37e52cba21238c (diff)
downloadPeerTube-d4eea028016092b36d9177616c9e6bb96df9abee.tar.gz
PeerTube-d4eea028016092b36d9177616c9e6bb96df9abee.tar.zst
PeerTube-d4eea028016092b36d9177616c9e6bb96df9abee.zip
Fix relative links in video description
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/angular/timestamp-route-transformer.directive.ts51
1 files changed, 25 insertions, 26 deletions
diff --git a/client/src/app/shared/angular/timestamp-route-transformer.directive.ts b/client/src/app/shared/angular/timestamp-route-transformer.directive.ts
index f4d9aeb1f..45e023695 100644
--- a/client/src/app/shared/angular/timestamp-route-transformer.directive.ts
+++ b/client/src/app/shared/angular/timestamp-route-transformer.directive.ts
@@ -10,31 +10,30 @@ export class TimestampRouteTransformerDirective {
10 public onClick ($event: Event) { 10 public onClick ($event: Event) {
11 const target = $event.target as HTMLLinkElement 11 const target = $event.target as HTMLLinkElement
12 12
13 if (target.hasAttribute('href')) { 13 if (target.hasAttribute('href') !== true) return
14 const ngxLink = document.createElement('a') 14
15 ngxLink.href = target.getAttribute('href') 15 const ngxLink = document.createElement('a')
16 16 ngxLink.href = target.getAttribute('href')
17 // we only care about reflective links 17
18 if (ngxLink.host !== window.location.host) return 18 // we only care about reflective links
19 19 if (ngxLink.host !== window.location.host) return
20 const ngxLinkParams = new URLSearchParams(ngxLink.search) 20
21 if (ngxLinkParams.has('start')) { 21 const ngxLinkParams = new URLSearchParams(ngxLink.search)
22 const separators = ['h', 'm', 's'] 22 if (ngxLinkParams.has('start') !== true) return
23 const start = ngxLinkParams 23
24 .get('start') 24 const separators = ['h', 'm', 's']
25 .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])','g')) // match digits before any given separator 25 const start = ngxLinkParams
26 .map(t => { 26 .get('start')
27 if (t.includes('h')) return parseInt(t, 10) * 3600 27 .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])','g')) // match digits before any given separator
28 if (t.includes('m')) return parseInt(t, 10) * 60 28 .map(t => {
29 return parseInt(t, 10) 29 if (t.includes('h')) return parseInt(t, 10) * 3600
30 }) 30 if (t.includes('m')) return parseInt(t, 10) * 60
31 .reduce((acc, t) => acc + t) 31 return parseInt(t, 10)
32 this.timestampClicked.emit(start) 32 })
33 } 33 .reduce((acc, t) => acc + t)
34 34
35 $event.preventDefault() 35 this.timestampClicked.emit(start)
36 } 36
37 37 $event.preventDefault()
38 return
39 } 38 }
40} 39}