Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
jio
Commits
489c41d3
Commit
489c41d3
authored
Mar 11, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[node] atob raises an Error if parameter is not a valid base64
Try to reproduce the browser specifications.
parent
101fd0ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
12 deletions
+5
-12
src/node/jio-compat.js
src/node/jio-compat.js
+5
-12
No files found.
src/node/jio-compat.js
View file @
489c41d3
...
...
@@ -190,11 +190,10 @@
try
{
return
window
.
atob
(
str
);
}
catch
(
err
)
{
var
buffer
;
if
(
str
instanceof
Buffer
)
{
buffer
=
str
;
}
else
{
buffer
=
Buffer
.
from
(
str
.
toString
(),
'
base64
'
);
var
buffer
=
Buffer
.
from
(
str
.
toString
(),
'
base64
'
);
// Provide the same behaviour than the browser atob
if
(
buffer
.
toString
(
'
base64
'
)
!==
str
)
{
throw
new
Error
(
'
The string to be decoded is not correctly encoded.
'
);
}
return
buffer
.
toString
(
'
binary
'
);
}
...
...
@@ -206,13 +205,7 @@
try
{
return
window
.
btoa
(
str
);
}
catch
(
err
)
{
var
buffer
;
if
(
str
instanceof
Buffer
)
{
buffer
=
str
;
}
else
{
buffer
=
Buffer
.
from
(
str
.
toString
(),
'
binary
'
);
}
return
buffer
.
toString
(
'
base64
'
);
return
Buffer
.
from
(
str
.
toString
(),
'
binary
'
).
toString
(
'
base64
'
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment