Fixed conversions that depend on pure JS modules
That is: - quoted printable - punycode - (utf8), dependency of quoted printable
This commit is contained in:
parent
710b703a8f
commit
1386babee5
11 changed files with 50 additions and 50 deletions
20
package.json
20
package.json
|
@ -19,14 +19,14 @@
|
|||
"url": "https://gittr.ch/manuel/dencode.org.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/common": "~2.4.0",
|
||||
"@angular/compiler": "~2.4.0",
|
||||
"@angular/core": "~2.4.0",
|
||||
"@angular/forms": "~2.4.0",
|
||||
"@angular/platform-browser": "~2.4.0",
|
||||
"@angular/platform-browser-dynamic": "~2.4.0",
|
||||
"@angular/common": "^2.4.0",
|
||||
"@angular/compiler": "^2.4.0",
|
||||
"@angular/core": "^2.4.0",
|
||||
"@angular/forms": "^2.4.0",
|
||||
"@angular/platform-browser": "^2.4.0",
|
||||
"@angular/platform-browser-dynamic": "^2.4.0",
|
||||
"core-js": "^2.4.1",
|
||||
"rxjs": "5.0.1",
|
||||
"rxjs": "^5.0.1",
|
||||
"zone.js": "^0.7.4",
|
||||
"bootstrap": "^3.3.0",
|
||||
"quoted-printable": "^1.0.0",
|
||||
|
@ -53,9 +53,9 @@
|
|||
"raw-loader": "^0.5.1",
|
||||
"rimraf": "^2.5.2",
|
||||
"style-loader": "^0.13.1",
|
||||
"typescript": "~2.0.10",
|
||||
"webpack": "2.2.1",
|
||||
"webpack-dev-server": "2.4.1",
|
||||
"typescript": "^2.0.10",
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-dev-server": "^2.4.1",
|
||||
"webpack-merge": "^3.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -15,7 +15,6 @@ export class PunycodeDecoder implements Converter {
|
|||
}
|
||||
|
||||
convert(input: string): string {
|
||||
// return this.nativeLibraryWrapperService.punycode.decode(input);
|
||||
return "";
|
||||
return this.nativeLibraryWrapperService.punycode.decode(input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ export class PunycodeEncoder implements Converter {
|
|||
}
|
||||
|
||||
convert(input: string): string {
|
||||
// return this.nativeLibraryWrapperService.punycode.encode(input);
|
||||
return "";
|
||||
return this.nativeLibraryWrapperService.punycode.encode(input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ export class QuotedPrintableDecoder implements Converter {
|
|||
}
|
||||
|
||||
convert(input:string):string {
|
||||
// try {
|
||||
// return this.nativeLibraryWrapperService.utf8.decode(this.nativeLibraryWrapperService.quotedPrintable.decode(input));
|
||||
// } catch (error) {
|
||||
try {
|
||||
return this.nativeLibraryWrapperService.utf8.decode(this.nativeLibraryWrapperService.quotedPrintable.decode(input));
|
||||
} catch (error) {
|
||||
throw new Error("The input can not be interpreted as quoted-printable. May be corrupt?");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ export class QuotedPrintableEncoder implements Converter {
|
|||
}
|
||||
|
||||
convert(input:string):string {
|
||||
// return this.nativeLibraryWrapperService.quotedPrintable.encode(this.nativeLibraryWrapperService.utf8.encode(input));
|
||||
return "";
|
||||
return this.nativeLibraryWrapperService.quotedPrintable.encode(this.nativeLibraryWrapperService.utf8.encode(input));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ import {DecToHexConverter} from "./converter/dectohexconverter";
|
|||
import {HexToDecConverter} from "./converter/hextodecconverter";
|
||||
import {DecToBinConverter} from "./converter/dectobinconverter";
|
||||
import {BinToDecConverter} from "./converter/bintodecconverter";
|
||||
// import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder";
|
||||
// import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder";
|
||||
import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder";
|
||||
import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder";
|
||||
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
|
||||
// import {PunycodeEncoder} from "./converter/punycodeencoder";
|
||||
// import {PunycodeDecoder} from "./converter/punycodedecoder";
|
||||
import {PunycodeEncoder} from "./converter/punycodeencoder";
|
||||
import {PunycodeDecoder} from "./converter/punycodedecoder";
|
||||
|
||||
@Injectable()
|
||||
export class ConverterRegistryService {
|
||||
|
@ -48,14 +48,14 @@ export class ConverterRegistryService {
|
|||
this.registerConverter(new URIComponentDecoder());
|
||||
this.registerConverter(new HTMLEntitiesEncoder());
|
||||
this.registerConverter(new HTMLEntitiesDecoder());
|
||||
// this.registerConverter(new QuotedPrintableEncoder(this.wrapper));
|
||||
// this.registerConverter(new QuotedPrintableDecoder(this.wrapper));
|
||||
this.registerConverter(new QuotedPrintableEncoder(this.wrapper));
|
||||
this.registerConverter(new QuotedPrintableDecoder(this.wrapper));
|
||||
this.registerConverter(new DecToHexConverter());
|
||||
this.registerConverter(new HexToDecConverter());
|
||||
this.registerConverter(new DecToBinConverter());
|
||||
this.registerConverter(new BinToDecConverter());
|
||||
// this.registerConverter(new PunycodeEncoder(this.wrapper));
|
||||
// this.registerConverter(new PunycodeDecoder(this.wrapper));
|
||||
this.registerConverter(new PunycodeEncoder(this.wrapper));
|
||||
this.registerConverter(new PunycodeDecoder(this.wrapper));
|
||||
}
|
||||
|
||||
private registerConverter(converter:Converter):void {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
|
||||
declare var utf8:any;
|
||||
declare var quotedPrintable:any;
|
||||
declare var punycode:any;
|
||||
import {Punycode} from "./punycode";
|
||||
import {Utf8} from "./utf8";
|
||||
import {QuotedPrintable} from "./quotedprintable";
|
||||
|
||||
@Injectable()
|
||||
export class NativeLibraryWrapperService {
|
||||
// public utf8:any;
|
||||
// public quotedPrintable:any;
|
||||
// public punycode:any;
|
||||
public utf8:Utf8;
|
||||
public quotedPrintable:QuotedPrintable;
|
||||
public punycode:Punycode;
|
||||
|
||||
constructor() {
|
||||
// this.utf8 = utf8;
|
||||
// this.quotedPrintable = quotedPrintable;
|
||||
// this.punycode = punycode;
|
||||
this.utf8 = require("utf8");
|
||||
this.quotedPrintable = require("quoted-printable");
|
||||
this.punycode = require("punycode");
|
||||
}
|
||||
}
|
||||
|
|
4
src/app/punycode.ts
Normal file
4
src/app/punycode.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface Punycode {
|
||||
encode(input:string):string;
|
||||
decode(input:string):string;
|
||||
}
|
4
src/app/quotedprintable.ts
Normal file
4
src/app/quotedprintable.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface QuotedPrintable {
|
||||
encode(input:string):string;
|
||||
decode(input:string):string;
|
||||
}
|
4
src/app/utf8.ts
Normal file
4
src/app/utf8.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface Utf8 {
|
||||
encode(input:any):string;
|
||||
decode(input:string):any;
|
||||
}
|
|
@ -1,13 +1,5 @@
|
|||
import {Component, Injectable, NgModule, OnInit} from "@angular/core";
|
||||
import {BrowserModule} from "@angular/platform-browser";
|
||||
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
|
||||
import "@angular/core";
|
||||
import "@angular/platform-browser";
|
||||
import "@angular/platform-browser-dynamic";
|
||||
import "@angular/forms";
|
||||
import "rxjs";
|
||||
|
||||
import "utf8";
|
||||
import "quoted-printable";
|
||||
import "punycode";
|
||||
require("utf8");
|
||||
require("quoted-printable");
|
||||
require("punycode");
|
||||
|
|
Loading…
Reference in a new issue