Repository navigation
π Critical Fixes for Cookies Handling
β Fixed Issues:
- Invalid character in header content ["Cookie"] - Cookies with special characters now work correctly
- Library crashes when cookies.txt is missing - Graceful fallback implemented
- Special characters in Google Analytics cookies - URL encoding added
β¨ New Features:
- Graceful fallback - Library works without AI functions when cookies are missing
- Optional cookies loading - Use to disable AI functions
- Cookie validation - Automatic validation of cookie format and characters
- Enhanced error handling - Informative messages without crashes
- isAIEnabled() method - Check if AI functions are available
π§ Improvements:
- 100% backward compatibility - Existing code continues to work
- Better reliability - Library always initializes successfully
- Enhanced security - Automatic encoding of special characters
- Improved developer experience - Clear error messages and graceful degradation
π Usage Examples:
// Graceful fallback - works with or without cookies
const builder = new CustomAPIBuilder();
await builder.init();
if (builder.isAIEnabled()) {
const result = await method.execute(data);
} else {
console.log('AI functions disabled, but library works');
}
// Explicitly disable AI functions
const builder = new CustomAPIBuilder({ skipCookies: true });
await builder.init();π§ͺ Testing:
- Comprehensive test suite included
- Tested with real cookies containing special characters
- All edge cases covered
π Files Changed:
src/k2think-dialog.js- Cookie encoding and validationsrc/api-builder.js- Graceful fallback implementationsrc/cookie-converter.js- Enhanced validation methods- Added comprehensive tests and documentation
This release fixes critical integration issues and makes the library much more reliable! π