Skip to content

fix a bug with relative path on output_dir - #250

Merged
masao merged 3 commits into
mainfrom
fix/output-dir-relative-path
Jul 11, 2026
Merged

fix a bug with relative path on output_dir#250
masao merged 3 commits into
mainfrom
fix/output-dir-relative-path

Conversation

@masao

@masao masao commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Fix an error in relative_path when @param[:output_dir] is specified.

Previously, Pathname#relative_path_from could receive a relative src path and an absolute output_dir path, causing the following error:

different prefix: "" and "/tmp/output"

This change normalizes both paths before calculating the relative path, so that path prefixes are consistent.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation or other updates (if none of the other choices apply)

Further comments

The error occurred because Pathname#relative_path_from requires both paths to use the same path prefix. When @param[:output_dir] was an absolute path but src was relative, the calculation failed.

The fix converts the relevant paths to absolute paths before calculating the path relative to output_dir.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f58216df2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/ttl2html/template.rb Outdated
@masao

masao commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b82d094a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/ttl2html/template.rb Outdated
@masao

masao commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6d61e79cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/ttl2html/template.rb
Comment on lines +149 to +151
src_path = Pathname.new(src).expand_path
src_relative = src_path.relative_path_from(base_dir)
path = Pathname.new(dest).relative_path_from(src_relative.dirname)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve relative src paths against output_dir

When output_dir is set to an absolute path and callers pass the still-supported relative src (for example relative_path_uri("a.html", ...), which is the case this change says it fixes), expanding src from the process cwd makes src_relative start with ..; the following relative_path_from(src_relative.dirname) then raises ArgumentError: base_directory has .. instead of producing the link. Relative src values should be resolved under output_dir before calculating src_relative.

Useful? React with 👍 / 👎.

@masao
masao merged commit 2d97e2f into main Jul 11, 2026
19 checks passed
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