Skip to content

Commit af2ebe7

Browse files
committed
new version fixing regEx error and HTML entities in get parameters
1 parent bd165a1 commit af2ebe7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Breinify.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@
309309
return null;
310310
} else if (value.charAt(0) === '.') {
311311
base64 = value.substr(1)
312-
.replace('/~/g', '+')
313-
.replace('/-/g', '/')
314-
.replace('/_/g', '=');
312+
.replace(/~/g, '+')
313+
.replace(/-/g, '/')
314+
.replace(/_/g, '=');
315315
} else {
316316
base64 = decodeURIComponent(value);
317317
}

src/BreinifyUtil.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@
9191
loc: {
9292

9393
params: function (paramListSeparator, paramSeparator, paramSplit, url) {
94-
url = typeof url === 'string' ? url : this.url();
94+
95+
// if the url is not passed in we use a special decoding for HTML entities
96+
// to avoid this, just pass in the url
97+
if (typeof url !== 'string') {
98+
var decoder = document.createElement('textarea');
99+
decoder.innerHTML = this.url();
100+
url = decoder.value;
101+
}
95102

96103
paramListSeparator = typeof paramListSeparator === 'string' ? paramListSeparator : '?';
97104
paramSeparator = typeof paramSeparator === 'string' ? paramSeparator : '&';

0 commit comments

Comments
 (0)