Skip to content

Commit

Permalink
Merge pull request #824 from tony-ho/fix-travis-build
Browse files Browse the repository at this point in the history
Fix Travis CI build failures on master
  • Loading branch information
thinkingserious authored Oct 30, 2018
2 parents 57b4e7b + f22811b commit 91e893f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
language: node_js
sudo: false
node_js:
- "4.1"
- "4.0"
- "0.12"
- "0.11"
- "0.10"
- "iojs"
- "6"
- "7"
- "8"
Expand All @@ -19,10 +12,7 @@ before_script:
- ./test/prism.sh
- yarn prism &
- sleep 5 # give it some time to start
install:
- npm install
script:
- npm test
- lerna bootstrap
- yarn test:files
- yarn test:license
Expand Down
28 changes: 16 additions & 12 deletions packages/mail/src/classes/mail-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,39 @@ class MailService {
rules = [rules];
}

const tmpRules = rules.map(function (rule) {
const tmpRules = rules.map(function(rule) {
const ruleType = typeof rule;

if (ruleType === 'string') {
return {
pattern: new RegExp(rule)
pattern: new RegExp(rule),
};
} else if (ruleType === 'object') {
}
else if (ruleType === 'object') {
// normalize rule object
if (rule instanceof RegExp) {
rule = {
pattern: rule
}
} else if (rule.hasOwnProperty('pattern')
pattern: rule,
};
}
else if (rule.hasOwnProperty('pattern')
&& (typeof rule.pattern === 'string')
) {
rule.pattern = new RegExp(rule.pattern);
rule.pattern = new RegExp(rule.pattern);
}

try {
// test if rule.pattern is a valid regex
rule.pattern.test('');
return rule
} catch (err) {
return rule;
}
catch (err) {
// continue regardless of error
}
}
});

this.secretRules = tmpRules.filter(function (val) {
this.secretRules = tmpRules.filter(function(val) {
return val;
});
}
Expand All @@ -102,8 +106,8 @@ class MailService {

const self = this;

body.content.forEach(function (data) {
self.secretRules.forEach(function (rule) {
body.content.forEach(function(data) {
self.secretRules.forEach(function(rule) {
if (rule.hasOwnProperty('pattern')
&& !rule.pattern.test(data.value)
) {
Expand Down

0 comments on commit 91e893f

Please sign in to comment.