-
Notifications
You must be signed in to change notification settings - Fork 137
feat: use origin based </x/y/>
relativisation rather than <../../../x/y/>
when result is a shorter relative IRI.
#529
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant BaseIRI
Caller->>BaseIRI: toRelative(targetIRI)
BaseIRI->>BaseIRI: _getBaseMatcher()
Note right of BaseIRI: Conditional path replacement<br>based on segment lengths
BaseIRI-->>Caller: Returns relative IRI
Assessment against linked issues
Possibly related PRs
Suggested labels
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn config production Use 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (2)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/BaseIRI.js
(2 hunks)test/BaseIRI-test.js
(1 hunks)
🔇 Additional comments (2)
test/BaseIRI-test.js (1)
144-148
: LGTM! Good test coverage for origin-based path optimization.These test cases effectively validate the new logic that prefers shorter origin-based paths over longer parent-based paths.
src/BaseIRI.js (1)
9-9
: LGTM! Good use of a named constant.Using a named constant for the origin character improves code readability and maintainability.
Do we want this though? Because a big reason for relative support in the writer is the ability to move documents without changing syntax. CC @smessie |
Although Therefore, I strongly recommend maintaining the current state and refraining from merging this PR. |
Right, that makes sense. The context for opening this PR is that I use the Given that I think this functionality would still be useful opt-in functionality in |
My two cents: pretty printing is a very different business from N3Writer. I'd architect the thing very differently for pretty printing (especially if the streaming constraint can be dropped). It could be an option on BaseIRI.js; wondering if it makes sense to forward base IRI options from N3Writer to BaseIRI. I'm mainly concerned about the slippery slope, in which N3Writer becomes no-actually-a-pretty-printer-but-some-features-are-getting-close-so-why-not, whereas the design goals are different. N3Writer is about writing Turtle fast (so any abbreviations are for speed more than readability), and features tend to serve a functional need (relative URIs are to facilitate moving). Pretty printers are inherently different beasts. |
Partially resolves #528 but does not cover the following test cases (where there are 2 or more sub paths after the relativisation):
Summary by CodeRabbit