Skip to content

Commit d7f6d5b

Browse files
Add browser tests
1 parent acfef4c commit d7f6d5b

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Simple parser for transparency and consent strings compatible with TCF2.0.
88

99
## Usage
1010

11-
### NodeJS
11+
### NodeJS (>=5.10.0)
1212

1313
```js
1414
const TCStringParse = require('tc-string-parse');
@@ -17,7 +17,7 @@ const consentString = ''; // your consent string
1717
TCStringParse(consentString);
1818
```
1919

20-
### Browser
20+
### Browser (IE 9+ with atob polyfill)
2121

2222
```html
2323
<script src="path/to/tc-string-parse.js"></script>

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
"devDependencies": {
1818
"ava": "3.5.1",
1919
"eslint": "6.8.0"
20+
},
21+
"engines": {
22+
"node": ">=5.10.0"
2023
}
2124
}

tc-string-parse.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
}(typeof self === "undefined" ? this : self, function () {
1212
var decodeBase64 = function (str) {
1313
if (typeof atob === "function") {
14-
return atob(str);
14+
var base64 = str.
15+
replace(/_/g, "/").
16+
replace(/-/g, "+");
17+
18+
return atob(base64);
1519
}
1620

1721
return Buffer.from(str, "base64").toString("binary");

tc-string-parse.test.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script src="tc-string-parse.js"></script>
2+
3+
<script>
4+
var consentString = "COuDmHAOuG5DAALAWhDAAcCMAP_AACAAACgAF0EWSQgAYWwho0QUBzBAIYAfJgSCAMgSAAQIoCkFQICERBAEKiAQHAEQJAAAGBAAkACBAQAoHCBMCQABgAARiRCEQECIDRNABIBAggAKYQFAAARmikHC3ZCY702yOmQAECAA.IF0EWSQgAYWwho0QUBzBAIYAfJgSCAMgSAAQIoCkFQICERBAEKiAQHAEQJAAAGBAAkACAAQAoHCBMCQABgAARiRCEQECIDRNABIBAggAKYQFAAARmikHC3ZCY702yOmQ.YAAAAAAAAAAAAAAAAAA";
5+
document.write(JSON.stringify(TCStringParse(consentString)));
6+
</script>

0 commit comments

Comments
 (0)