diff options
Diffstat (limited to 'webAO/utils/getCookie.js')
| -rw-r--r-- | webAO/utils/getCookie.js | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/webAO/utils/getCookie.js b/webAO/utils/getCookie.js index 000c870..3be0733 100644 --- a/webAO/utils/getCookie.js +++ b/webAO/utils/getCookie.js @@ -5,22 +5,22 @@ * @param {String} cname The name of the cookie to return */ const getCookie = (cname) => { - try { - const name = `${cname}=`; - const decodedCookie = decodeURIComponent(document.cookie); - const ca = decodedCookie.split(';'); - for (let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) === ' ') { - c = c.substring(1); - } - if (c.indexOf(name) === 0) { - return c.substring(name.length, c.length); - } + try { + const name = `${cname}=`; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(';'); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); } - return ''; - } catch (error) { - return ''; } + return ''; + } catch (error) { + return ''; } - export default getCookie;
\ No newline at end of file +}; +export default getCookie; |
