diff options
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/foundation/metrics/cookies.js')
| -rw-r--r-- | node_modules/@jet-app/app-store/tmp/src/foundation/metrics/cookies.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/metrics/cookies.js b/node_modules/@jet-app/app-store/tmp/src/foundation/metrics/cookies.js new file mode 100644 index 0000000..5005b72 --- /dev/null +++ b/node_modules/@jet-app/app-store/tmp/src/foundation/metrics/cookies.js @@ -0,0 +1,27 @@ +import { isNothing } from "@jet/environment/types/optional"; +/** + * Iterate the cookies contained in a string. + * + * @param cookie A string containing zero or more cookies. + */ +export function* cookiesOf(cookie) { + if (isNothing(cookie)) { + return; + } + const rawEntries = cookie.split(";"); + for (const rawEntry of rawEntries) { + const keyEndIndex = rawEntry.indexOf("="); + if (keyEndIndex === -1) { + // If there's no splitter, treat the whole raw + // entry as the key and provide an empty value. + const key = decodeURIComponent(rawEntry).trim(); + yield { key, value: "" }; + } + else { + const key = decodeURIComponent(rawEntry.substring(0, keyEndIndex)).trim(); + const value = decodeURIComponent(rawEntry.substring(keyEndIndex + 1)).trim(); + yield { key, value }; + } + } +} +//# sourceMappingURL=cookies.js.map
\ No newline at end of file |
