Skip to content

Commit

Permalink
fix: add isURL check
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Apr 7, 2023
1 parent 2ec8711 commit 4741d0a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const unified = require('unified');
const universalify = require('universalify');
const vfile = require('to-vfile');
const { v2 } = require('@google-cloud/translate');
const { isEmail } = require('validator');
const { isEmail, isURL } = require('validator');

const isoCodes = Object.keys(languages.getAlpha2Codes());
const writeFile = pify(fs.writeFile);
Expand Down Expand Up @@ -304,8 +304,8 @@ class Mandarin {
const key = `${locale}:${revHash(phrase)}`;
let translation;

// do not translate if it is an email, FQDN, or IP
if (isEmail(phrase) || isFQDN(phrase) || isIP(phrase))
// do not translate if it is an email, FQDN, URL, or IP
if (isEmail(phrase) || isFQDN(phrase) || isURL(phrase) || isIP(phrase))
translation = phrase;
else if (this.redisClient)
translation = await this.redisClient.get(key);
Expand Down

0 comments on commit 4741d0a

Please sign in to comment.