feat: add realpath to print an item's View Online URL - #74
Open
lionello wants to merge 1 commit into
Open
Conversation
Answers #12: print the item's own `webUrl`, which exists whether or not the file has ever been shared -- unlike the sharing link `ln` mints via `createLink`. Accepts a remote path, or a local path inside the folder the OneDrive sync client mirrors. Sync roots come from $OneDrive/$OneDriveConsumer/ $OneDriveCommercial, ~/OneDrive, and ~/Library/CloudStorage/OneDrive* (the leaf name varies per tenant on macOS). Only ~, ., / or drive-letter prefixed arguments are treated as local, and an absolute path outside every sync root falls through to remote, so `ls /Public` keeps working. The mapping is textual: it does not consult the sync client's database, so a local file renamed on conflict would resolve to the wrong item. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #12.
realpathprints an item's ownwebUrl— the View Online address, which exists whether or not the file has ever been shared. That is deliberately not whatlndoes:lncallscreateLinkand mints a new sharing permission, and the URL it prints only exists because you shared the file. Different things, which is why #12 stayed open alongsideln.Naming:
realpathis the POSIX/coreutils verb for "take this name and give me its one true canonical form", which is exactly whatwebUrlis.readlinkwould be wrong — it means "print what this link points at", and nothing here is a link.Both directions
Sync roots come from
$OneDrive/$OneDriveConsumer/$OneDriveCommercial(set by the Windows client),~/OneDrive, and any~/Library/CloudStorage/OneDrive*— the leaf name varies per tenant on macOS, so it is discovered rather than hardcoded.Only
~-,.-,/- or drive-letter-prefixed arguments are considered local, and an absolute path outside every sync root falls through to remote, soonedrive ls /Public-style paths keep working unchanged.Verified against a live drive
Same file three ways — remote path, absolute local path,
~-relative local path — all print the same URL. A nested path (Xcj/WP_20130227_004.jpg) maps correctly,/etc/hostsfalls back to remote and reports not-found, and no arguments gives the drive root.npm run lintandprettier --checkare clean.Known limitation
The local→remote mapping is purely textual; it does not consult the sync client's database. A file whose local name differs from its remote one (the sync client's rename-on-conflict) would resolve to the wrong item. Reading the real metadata is a larger job, left out of scope.
🤖 Generated with Claude Code