Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Option to disable URL encoding in cookie #11

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion angular-cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ angular.module('ngCookies', ['ng']).
* - **expires** - `{string|Date}` - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT"
* or a Date object indicating the exact date/time this cookie will expire.
* - **secure** - `{boolean}` - The cookie will be available only in secured connection.
* - **encoding** -- '{boolean}' - The cookie will be encoded in javascript URL encoding.
*
* Note: by default the address that appears in your `<base>` tag will be used as path.
* This is important so that cookies will be visible for all routes in case html5mode is enabled
Expand Down Expand Up @@ -286,7 +287,13 @@ function $$CookieWriter($document, $log, $browser) {
expires = new Date(expires);
}

var str = encodeURIComponent(name) + '=' + encodeURIComponent(value);
if(options.encoding || angular.isUndefined(options.encoding)) {
var str = encodeURIComponent(name) + '=' + encodeURIComponent(value);
}
else {
var str = (name) + '=' + (value);
}

str += path ? ';path=' + path : '';
str += options.domain ? ';domain=' + options.domain : '';
str += expires ? ';expires=' + expires.toUTCString() : '';
Expand Down