fix(site_generation): use shared URL util for site links#52
Merged
anchildress1 merged 1 commit intomainfrom Jan 31, 2026
Merged
fix(site_generation): use shared URL util for site links#52anchildress1 merged 1 commit intomainfrom
anchildress1 merged 1 commit intomainfrom
Conversation
- build related post hrefs without duplicating the posts path segment - compute HOME/ROOT_HOME via shared url_utils helper - add URL utility module and unit tests for success/error/edge cases Generated-by: GitHub Copilot <copilot@github.com> Signed-off-by: Ashley Childress <6563688+anchildress1@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new url_utils module to centralize URL handling and fixes a bug where related post links were duplicating the "posts" path segment (e.g., /posts/posts/foo.html). The changes include comprehensive unit tests and minor improvements to the build quality checks.
Changes:
- Introduced
src/devto_mirror/core/url_utils.pywith functions for normalizing domains, building site URLs, and generating safe post page hrefs - Refactored
generator.py,renderer.py, andcross_reference.pyto use the new centralized URL utilities - Added comprehensive unit tests in
tests/test_url_utils.pyincluding regression tests for the duplicate path bug - Increased test coverage threshold from 80% to 80.9% and made complexity checks fail the build instead of just warning
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/devto_mirror/core/url_utils.py |
New module providing centralized URL utilities with proper validation and security checks (path traversal prevention) |
tests/test_url_utils.py |
Comprehensive unit tests for URL utilities and regression test for the duplicate "posts" path segment bug |
src/devto_mirror/site_generation/generator.py |
Refactored to use build_site_urls() for computing HOME and ROOT_HOME instead of inline string formatting |
src/devto_mirror/site_generation/renderer.py |
Refactored to use build_site_urls() with proper exception handling |
src/devto_mirror/ai_optimization/cross_reference.py |
Refactored related links generation to use post_page_href(), fixing the duplicate path segment bug; extracted helper functions for better code organization |
Makefile |
Increased test coverage threshold to 80.9% and made complexity checks fail the build instead of warning |
This was referenced Feb 1, 2026
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.
Generated-by: GitHub Copilot copilot@github.com
This pull request introduces a new
url_utilsmodule to centralize and improve URL handling for the site, refactors related code to use these utilities, and adds comprehensive tests to ensure correctness. The changes also include a minor adjustment to the test coverage threshold and a stricter complexity check in the Makefile.URL Handling Improvements:
src/devto_mirror/core/url_utils.pymodule that provides centralized utilities for building site URLs, normalizing domains, and generating safe post page hrefs; this prevents duplicated path segments and path traversal issues.src/devto_mirror/ai_optimization/cross_reference.py,src/devto_mirror/site_generation/generator.py, andsrc/devto_mirror/site_generation/renderer.pyto use the new URL utilities, ensuring consistent and correct URL construction throughout the codebase. [1] [2] [3] [4] [5] [6]Testing and Validation:
tests/test_url_utils.pywith comprehensive unit tests for all new URL utility functions and for the related links feature, including regression tests to ensure no duplicated "posts" path segments appear in generated links.Related Links Logic Refactor:
cross_reference.pyto use new helper functions for tag cleaning, scoring, and safe local link construction, improving code clarity and robustness. [1] [2] [3]Build and Quality Checks: