converter/src/app/converter/uriencoder.ts

16 lines
307 B
TypeScript
Raw Normal View History

2017-04-15 19:04:49 +02:00
import {Converter} from './converter';
2016-09-20 20:45:04 +02:00
export class URIEncoder implements Converter {
getDisplayname(): string {
2017-04-15 19:04:49 +02:00
return 'Encode URI';
}
2016-09-20 20:45:04 +02:00
getId(): string {
2017-04-15 19:04:49 +02:00
return 'uriencode';
}
2016-09-20 20:45:04 +02:00
convert(input: string): string {
return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']');
}
2016-09-20 20:45:04 +02:00
}