feat(wire): Add wire protocol, WireTarget & WireParser, Smartmail JSON serialization; refactor plugins and update dependencies
This commit is contained in:
@@ -251,8 +251,9 @@ export class EmailAddressValidator {
|
||||
*/
|
||||
public async fetchDomains() {
|
||||
if (!this.domainMap) {
|
||||
const localFileString = plugins.smartfile.fs.toStringSync(
|
||||
plugins.path.join(paths.assetDir, 'domains.json')
|
||||
const localFileString = plugins.fs.readFileSync(
|
||||
plugins.path.join(paths.assetDir, 'domains.json'),
|
||||
'utf8'
|
||||
);
|
||||
const localFileObject = JSON.parse(localFileString);
|
||||
|
||||
@@ -262,12 +263,10 @@ export class EmailAddressValidator {
|
||||
}
|
||||
|
||||
try {
|
||||
const onlineFileObject = (
|
||||
await plugins.smartrequest.getJson(
|
||||
'https://raw.githubusercontent.com/romainsimon/emailvalid/master/domains.json'
|
||||
)
|
||||
).body;
|
||||
this.domainMap = onlineFileObject;
|
||||
const response = await plugins.SmartRequest.create()
|
||||
.url('https://raw.githubusercontent.com/romainsimon/emailvalid/master/domains.json')
|
||||
.get();
|
||||
this.domainMap = await response.json();
|
||||
} catch (e) {
|
||||
this.domainMap = localFileObject;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user