2017-04-15 19:04:49 +02:00
|
|
|
import {Converter} from './converter';
|
2016-09-15 20:43:37 +02:00
|
|
|
|
|
|
|
export class Base64Decoder implements Converter {
|
2017-04-15 18:51:22 +02:00
|
|
|
getDisplayname(): string {
|
2017-04-15 19:04:49 +02:00
|
|
|
return 'Decode Base 64';
|
2017-04-15 18:51:22 +02:00
|
|
|
}
|
2016-09-15 20:43:37 +02:00
|
|
|
|
2017-04-15 18:51:22 +02:00
|
|
|
getId(): string {
|
2017-04-15 19:04:49 +02:00
|
|
|
return 'base64decode';
|
2017-04-15 18:51:22 +02:00
|
|
|
}
|
2016-09-15 20:43:37 +02:00
|
|
|
|
2017-04-15 18:51:22 +02:00
|
|
|
convert(input: string): string {
|
|
|
|
try {
|
|
|
|
return atob(input);
|
|
|
|
} catch (exception) {
|
2017-04-15 19:04:49 +02:00
|
|
|
throw new Error('Could not decode base64 string. Maybe corrupt input?');
|
2016-09-15 20:43:37 +02:00
|
|
|
}
|
2017-04-15 18:51:22 +02:00
|
|
|
}
|
2016-09-15 20:43:37 +02:00
|
|
|
}
|