Skip to content

Join Url paths with forward slashes instead of OS#934

Merged
chrisvire merged 3 commits intosillsdev:mainfrom
chrisvire:fix/web-path
Jan 27, 2026
Merged

Join Url paths with forward slashes instead of OS#934
chrisvire merged 3 commits intosillsdev:mainfrom
chrisvire:fix/web-path

Conversation

@chrisvire
Copy link
Member

@chrisvire chrisvire commented Jan 27, 2026

  • On Windows, the contents images had back slashes in paths intended for web pages and messed up the path processing.

Summary by CodeRabbit

  • New Features

    • Added a URL-safe path-joining utility for consistent, web-friendly path construction.
    • Applied this utility across image, link, manifest, and stylesheet processing so generated URLs are built uniformly.
  • Bug Fixes

    • Fixed inconsistent path formatting to ensure produced asset and link URLs are correctly structured for web use.

✏️ Tip: You can customize this high-level summary in your review settings.

@chrisvire chrisvire requested a review from FyreByrd January 27, 2026 19:19
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Warning

Rate limit exceeded

@chrisvire has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds an exported joinUrlPath(...parts: string[]) in convert/fileUtils.ts (uses path.posix) and updates multiple converters to build URL-style paths with it instead of manual string concatenation or join().

Changes

Cohort / File(s) Summary
URL join utility
convert/fileUtils.ts
Adds exported joinUrlPath(...parts: string[]) using path.posix. Replaces join() usage when computing hashedPath in createHashedFile and createHashedFileFromContents.
Book conversion image handling
convert/convertBooks.ts
Imports joinUrlPath and replaces manual ${base}/${imagePath} and fileName concatenation with joinUrlPath('illustrations', fileName) and joinUrlPath(base, imagePath).
Content link construction
convert/convertContents.ts
Adds joinUrlPath import, tightens a truthiness check for linkTarget, and replaces string interpolation for linkLocation with joinUrlPath(linkType, collection.id, linkTarget).
Manifest path update
convert/convertManifest.ts
Imports joinUrlPath and replaces literal "./<name>" replacement with joinUrlPath('.', <name>) when updating manifest src.
Styles / fonts path replacement
convert/convertStyles.ts
Imports joinUrlPath and replaces line.replace('/fonts', \$assets/${finalPath}`)withline.replace('/fonts', joinUrlPath('$assets', finalPath))`.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hop on paths with perfect slash,
POSIX trails avoid a clash.
joinUrlPath threads each file through,
Neat URLs, all fresh and new. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly addresses the main change: introducing URL-safe path joining with forward slashes instead of OS-dependent separators, which is the core objective across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- On Windows, the contents images had back slashes in paths intended for
  web pages and messed up the path processing.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@convert/fileUtils.ts`:
- Around line 79-82: joinUrlPath currently calls posix.join(...parts) but does
not normalize Windows backslashes, so segments containing '\' will be preserved;
update joinUrlPath to first map over the incoming parts and replace all
backslashes with forward slashes (e.g., part.replace(/\\/g, '/')) before calling
posix.join, ensuring any trailing/leading backslashes are normalized to POSIX
separators and the returned path is always POSIX-style; keep the function name
joinUrlPath and the posix.join call but feed it the normalized segments.

@chrisvire chrisvire changed the title Join web paths with forward slashes instead of OS Join Url paths with forward slashes instead of OS Jan 27, 2026
@chrisvire chrisvire merged commit 64aedf1 into sillsdev:main Jan 27, 2026
4 checks passed
@chrisvire chrisvire deleted the fix/web-path branch January 27, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant