Skip to content

Commit

Permalink
Make use of ternary operator instead of if/else
Browse files Browse the repository at this point in the history
This way value + key appear together, visually.
  • Loading branch information
carhartl committed Feb 16, 2018
1 parent d53efd3 commit 7441ec7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/js.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@
}
} catch (e) {}

if (!converter.write) {
value = encodeURIComponent(String(value))
value = converter.write ?
converter.write(value, key) :
encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}

key = encodeURIComponent(String(key))
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
Expand Down

0 comments on commit 7441ec7

Please sign in to comment.