forked from react-ga/react-ga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request react-ga#402 from hilezir/dev
add options.redactEmail, fix react-ga#144
- Loading branch information
Showing
9 changed files
with
309 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8.9.0 | ||
12.13.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import mightBeEmail from './mightBeEmail'; | ||
import redactEmail from './redactEmail'; | ||
import toTitleCase from './toTitleCase'; | ||
import warn from './console/warn'; | ||
|
||
const redacted = 'REDACTED (Potential Email Address)'; | ||
export default function format(s = '', titleCase, redactingEmail = true) { | ||
let _str = s || ''; | ||
|
||
export default function format(s, titleCase) { | ||
if (mightBeEmail(s)) { | ||
warn('This arg looks like an email address, redacting.'); | ||
return redacted; | ||
if (titleCase) { | ||
_str = toTitleCase(s); | ||
} | ||
|
||
if (titleCase) { | ||
return toTitleCase(s); | ||
if (redactingEmail) { | ||
_str = redactEmail(_str); | ||
} | ||
|
||
return s; | ||
return _str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import warn from './console/warn'; | ||
import mightBeEmail from './mightBeEmail'; | ||
|
||
const redacted = 'REDACTED (Potential Email Address)'; | ||
|
||
export default function redactEmail(string) { | ||
if (mightBeEmail(string)) { | ||
warn('This arg looks like an email address, redacting.'); | ||
return redacted; | ||
} | ||
|
||
return string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,14 @@ import sinon from 'sinon'; | |
import format from '../../src/utils/format'; | ||
|
||
describe('format()', function () { | ||
it('should not format when redactingEmail is false', function () { | ||
const titleCase = false; | ||
const redactingEmail = false; | ||
format('[email protected]', titleCase, redactingEmail).should.eql('[email protected]'); | ||
format('[email protected]', titleCase, redactingEmail).should.eql('[email protected]'); | ||
format('[email protected]', titleCase, redactingEmail).should.eql('[email protected]'); | ||
}); | ||
|
||
it('should not format email addresses', function () { | ||
sinon.stub(console, 'warn'); | ||
console.warn.callCount.should.eql(0); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters