Skip to content

Commit

Permalink
Move RFC 6265 related functionality to converter
Browse files Browse the repository at this point in the history
  • Loading branch information
carhartl committed Aug 27, 2021
1 parent 9e45d88 commit fee39fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ function init (converter, defaultAttributes) {
var parts = cookies[i].split('=')
var value = parts.slice(1).join('=')

if (value[0] === '"') {
value = value.slice(1, -1)
}

try {
var foundKey = decodeURIComponent(parts[0])
jar[foundKey] = converter.read(value, foundKey)
Expand Down
3 changes: 3 additions & 0 deletions src/converter.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable no-var */
export default {
read: function (value) {
if (value[0] === '"') {
value = value.slice(1, -1)
}
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
},
write: function (value) {
Expand Down

0 comments on commit fee39fc

Please sign in to comment.