Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Roque
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
Show 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 @@
...
@@ -190,11 +190,10 @@
try
{
try
{
return
window
.
atob
(
str
);
return
window
.
atob
(
str
);
}
catch
(
err
)
{
}
catch
(
err
)
{
var
buffer
;
var
buffer
=
Buffer
.
from
(
str
.
toString
(),
'
base64
'
);
if
(
str
instanceof
Buffer
)
{
// Provide the same behaviour than the browser atob
buffer
=
str
;
if
(
buffer
.
toString
(
'
base64
'
)
!==
str
)
{
}
else
{
throw
new
Error
(
'
The string to be decoded is not correctly encoded.
'
);
buffer
=
Buffer
.
from
(
str
.
toString
(),
'
base64
'
);
}
}
return
buffer
.
toString
(
'
binary
'
);
return
buffer
.
toString
(
'
binary
'
);
}
}
...
@@ -206,13 +205,7 @@
...
@@ -206,13 +205,7 @@
try
{
try
{
return
window
.
btoa
(
str
);
return
window
.
btoa
(
str
);
}
catch
(
err
)
{
}
catch
(
err
)
{
var
buffer
;
return
Buffer
.
from
(
str
.
toString
(),
'
binary
'
).
toString
(
'
base64
'
);
if
(
str
instanceof
Buffer
)
{
buffer
=
str
;
}
else
{
buffer
=
Buffer
.
from
(
str
.
toString
(),
'
binary
'
);
}
return
buffer
.
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