18 lines
393 B
TypeScript
18 lines
393 B
TypeScript
import {Converter} from './converter';
|
|
|
|
export class URIComponentEncoder implements Converter {
|
|
getDisplayname(): string {
|
|
return 'Encode URI component';
|
|
}
|
|
|
|
getId(): string {
|
|
return 'uricomponentencode';
|
|
}
|
|
|
|
convert(input: string): string {
|
|
return encodeURIComponent(input).replace(/[!'()*]/g, function (c) {
|
|
return '%' + c.charCodeAt(0).toString(16);
|
|
});
|
|
}
|
|
}
|