Fix port number preservation in CSS import URI resolution#432
Merged
martinnormark merged 1 commit intomainfrom Jun 26, 2025
Merged
Fix port number preservation in CSS import URI resolution#432martinnormark merged 1 commit intomainfrom
martinnormark merged 1 commit intomainfrom
Conversation
- Add test to verify port numbers are preserved when resolving relative CSS imports - Remove Port = -1 assignment in GetBaseUri() method that was stripping port numbers - Fixes issue #431 where URIs with port numbers became inaccessible since version 2.7.0 Co-Authored-By: Martin <m@martinnormark.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
martinnormark
approved these changes
Jun 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix port number preservation in CSS import URI resolution
Summary
Fixes issue #431 where port numbers were being discarded from URIs when resolving relative CSS imports since version 2.7.0. The bug was in the
GetBaseUri()method inImportRuleCssSource.cs, which explicitly setPort = -1to exclude port numbers when creating base URIs for resolving relative imports.Changes:
Port = -1assignment inImportRuleCssSource.GetBaseUri()to preserve port numbersItShould_PreservePortNumber_WhenResolvingRelativeImports()to verify the fixImpact: This enables CSS imports to work correctly when the base stylesheet is served from a non-standard port (e.g., development servers on localhost:8080).
Review & Testing Checklist for Human
Diagram
graph TD A[PreMailer.cs] --> B[LinkTagCssSource.cs] B --> C[ImportRuleCssSource.cs]:::major-edit C --> D[GetBaseUri method]:::major-edit D --> E[UriBuilder construction] F[ImportRuleCssSourceTests.cs]:::major-edit --> G[New port preservation test]:::major-edit H[CSS with @import] --> C C --> I[WebDownloader.DownloadString] subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Link to Devin run: https://app.devin.ai/sessions/f46a471d948c4b60a7c1d1ee817eccc9
Requested by: @martinnormark