/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MAIN //

/**
* Returns a cookie string for a provided name-value pair.
*
* @private
* @param {string} name - cookie name
* @param {string} value - cookie value
* @param {Object} [options] - cookie options
* @param {string} [options.path] - cookie path
* @param {string} [options.domain] - cookie domain
* @param {number} [options.maxAge] - maximum age (in seconds; takes precedence over `expire`)
* @param {(string|Date)} [options.expires] - cookie expiration date
* @param {boolean} [options.secure] - boolean indicating whether the cookie may only be transmitted over a secure protocol (e.g., HTTPS)
* @param {string} [options.samesite] - specifies whether the browser should send this cookie along with cross-site requests
* @returns {(string|null)} cookie value (or null)
*/
function cookieString( name, value, options ) {
	var opts;
	var keys;
	var tmp;
	var k;
	var v;
	var i;

	opts = {
		'path': '/',
		'max-age': 31536000, // 60*60*24*365 (1 year)
		'secure': true,
		'samesite': 'strict'
	};
	if ( arguments.length > 2 ) {
		if ( options.path ) {
			opts.path = options.path;
		}
		if ( options.domain ) {
			opts.domain = options.domain;
		}
		if ( typeof options.maxAge === 'number' ) {
			opts[ 'max-age' ] = options.maxAge;
		}
		if ( options.expires ) {
			if ( options.expires instanceof Date ) {
				opts.expires = options.expires.toUTCString();
			} else {
				opts.expires = options.expires;
			}
		}
		if ( typeof options.secure === 'boolean' ) {
			opts.secure = options.secure;
		}
		if ( options.samesite ) {
			opts.samesite = options.samesite;
		}
	}
	tmp = [ name + '=' + encodeURIComponent( value ) ];
	keys = Object.keys( opts );
	for ( i = 0; i < keys.length; i++ ) {
		k = keys[ i ];
		v = opts[ k ];
		if ( k === 'secure' && v ) {
			tmp.push( k );
		} else {
			tmp.push( k + '=' + v );
		}
	}
	return tmp.join( '; ' );
}


// EXPORTS //

module.exports = cookieString;

@@ -1535,16 +1535,24 @@
 ath': '/
+docs/api
 ',%0A%09%09'ma

Update path