-
Notifications
You must be signed in to change notification settings - Fork 291
Release v3.1.0 - Critical Bug Fixes & Enhanced Robustness #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Created 17 comprehensive tests with 47 assertions - Documents GLightbox scenario from issue #173 - Tests all edge cases: type attributes, async, integrity, crossorigin - Tests JSON-LD, module scripts, nomodule, empty src - Tests relative/absolute paths, protocol-relative URLs - Tests single/double quotes and no quotes - Performance test: 100 scripts in <100ms - All 62 tests passing with 246 assertions - Relates to #173
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This release focuses on critical bug fixes and comprehensive test coverage improvements for the Laravel PageSpeed package. The primary issues addressed include JavaScript comment removal breaking URLs, DNS prefetch extracting URLs from JSON-LD/script content, and PCRE errors with large HTML documents.
Key Changes:
- Refactored RemoveComments middleware with character-by-character parsing to preserve URLs in JavaScript strings
- Fixed InsertDNSPrefetch to only extract URLs from HTML resource attributes, not script/style content
- Added PCRE error handling for large HTML documents to prevent blank pages
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| protected function getMiddleware() | ||
| { | ||
| $this->middleware = new DeferJavascript(); | ||
| } |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getMiddleware() method sets $this->middleware but does not return it, and the property is never used in any test. This method appears to be dead code that should be removed, or it should return the middleware instance if it's intended to be used.
| protected function getMiddleware() | |
| { | |
| $this->middleware = new DeferJavascript(); | |
| } |
|
|
||
| // Should NOT modify inline script (no src attribute means no defer added) | ||
| $this->assertStringContainsString("console.log('inline');", $actual); | ||
| $this->assertStringNotContainsString("console.log('inline');" . ' defer', $actual); |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string concatenation \"console.log('inline');\" . ' defer' is unnecessarily complex. This should be simplified to a single string literal: \"console.log('inline'); defer\".
| $this->assertStringNotContainsString("console.log('inline');" . ' defer', $actual); | |
| $this->assertStringNotContainsString("console.log('inline'); defer", $actual); |
🔍 Pull Request Validation Results
Automated validation by GitHub Actions |
🎉 Release v3.1.0 - Critical Bug Fixes & Enhanced Robustness
This release includes critical bug fixes and significantly improved test coverage to ensure package stability and reliability.
🐛 Critical Bug Fixes
1. JavaScript Comment Removal Bug (#180, #184)
Issue: The
RemoveCommentsmiddleware was incorrectly removing//characters inside JavaScript strings, breaking code like:Fix:
http://,https://,://)Tests: 8 new comprehensive tests covering edge cases
Fixes: #180, #184
2. InsertDNSPrefetch Extracting URLs from JSON-LD (#179)
Issue: The
InsertDNSPrefetchmiddleware was incorrectly extracting URLs from:<script type="application/ld+json">)<script>tags<style>tagsThis caused unwanted DNS prefetch tags and SEO issues.
Fix:
<script src>,<link href>,<img src>,<a href>,<iframe src>,<video>,<audio>,<source>Tests: 3 new tests for JSON-LD, JavaScript, and edge cases
Fixes: #179
3. PCRE Error Handling for Large HTML
Issue: Large HTML documents could exceed PCRE backtrack/recursion limits, causing blank pages.
Fix:
PageSpeed::replace()Tests: 2 tests with 5,000 and 20,000 line HTML documents
Related: #184
📚 Documentation & Test Coverage
DeferJavascript Comprehensive Test Suite (#173)
Added: 17 extremely robust tests (47 assertions) documenting all edge cases:
✅ Basic Functionality:
data-pagespeed-no-defer✅ Edge Cases:
✅ GLightbox Scenario: Documents the exact issue from #173 with 4 solution options
Related: #173
🔧 Dependency Updates
orchestra/testbench→ ^10.6.0actions/checkout→ v5actions/cache→ v4actions/github-script→ v8📊 Test Results
🚀 Impact
Performance
Stability
Compatibility
📝 Breaking Changes
None - This is a bug fix release maintaining full backward compatibility.
🎯 Closed Issues
📦 Installation
Or for immediate access to these fixes:
{ "require": { "vinkius-labs/laravel-page-speed": "dev-develop" } }👥 Contributors
@renatomarinho - All bug fixes and test coverage improvements
Ready to merge: All tests passing, no conflicts, fully backward compatible.