encode download links (closes #104)

This commit is contained in:
Alex Shnitman 2022-01-14 09:11:03 +02:00
parent 62570a0a40
commit 622ca428e3
3 changed files with 12 additions and 2 deletions

View File

@ -120,7 +120,7 @@
<fa-icon *ngIf="download.value.status == 'finished'" [icon]="faCheckCircle" style="color: green;"></fa-icon>
<fa-icon *ngIf="download.value.status == 'error'" [icon]="faTimesCircle" style="color: red;"></fa-icon>
</div>
<span ngbTooltip="{{download.value.msg}}"><a *ngIf="!!download.value.filename; else noDownloadLink" href="download/{{download.value.filename}}" target="_blank">{{ download.value.title }}</a></span>
<span ngbTooltip="{{download.value.msg}}"><a *ngIf="!!download.value.filename; else noDownloadLink" href="download/{{download.value.filename | encodeURIComponent}}" target="_blank">{{ download.value.title }}</a></span>
<ng-template #noDownloadLink>{{ download.value.title }}</ng-template>
</td>
<td>

View File

@ -7,7 +7,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { CookieService } from 'ngx-cookie-service';
import { AppComponent } from './app.component';
import { EtaPipe, SpeedPipe } from './downloads.pipe';
import { EtaPipe, SpeedPipe, EncodeURIComponent } from './downloads.pipe';
import { MasterCheckboxComponent, SlaveCheckboxComponent } from './master-checkbox.component';
import { MeTubeSocket } from './metube-socket';
@ -16,6 +16,7 @@ import { MeTubeSocket } from './metube-socket';
AppComponent,
EtaPipe,
SpeedPipe,
EncodeURIComponent,
MasterCheckboxComponent,
SlaveCheckboxComponent
],

View File

@ -35,3 +35,12 @@ export class SpeedPipe implements PipeTransform {
return parseFloat((value / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
}
@Pipe({
name: 'encodeURIComponent'
})
export class EncodeURIComponent implements PipeTransform {
transform(value: string, ...args: any[]): any {
return encodeURIComponent(value);
}
}