Skip to content

fix: resolve document refs from browser URLs with anchors, queries or trailing paths - #155

Merged
scottlovegrove merged 2 commits into
Doist:mainfrom
andriykohut:fix/doc-url-refs
Oct 23, 2026
Merged

scottlovegrove merged 2 commits into
Doist:mainfrom
andriykohut:fix/doc-url-refs

Conversation

@andriykohut

@andriykohut andriykohut commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Document refs copied from the browser didn't resolve when the URL had anything after the slug: a #heading anchor, a ?query string, or a trailing path such as /edit or /history/<revision>. The ID was taken from the last path segment, so ol doc get https://wiki.example.com/doc/my-doc-AbC123#setup skipped the ID lookup, fetched every document to try a title match, and then reported Document not found.

The slug is now read from the /doc/<slug> segment, ignoring the query and fragment. Input without /doc/ (bare slugs, IDs, titles) takes the same path as before.

Tested: npm test (240 passing, with a new case for each URL shape), type-check, lint, format and the skill sync check. Against self-hosted Outline 1.11.0, one document resolves to the same ID from its plain URL and with a trailing /, #anchor, ?query, /edit and /history#… appended.

… trailing paths

The document ID was taken from the last path segment of the input, so
URLs copied from the browser (`/doc/<slug>#heading`, `?query`, `/edit`,
`/history/...`) missed the ID lookup and fell through to a full title
scan that reported "not found". Read the slug from the `/doc/<slug>`
segment instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@scottlovegrove scottlovegrove left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, the fix looks right and the URL shapes in the test cover what people actually paste. One small follow-on suggestion inline.

Comment thread src/lib/refs.ts
Outline also serves documents at `/doc/<urlId>`. That segment has no
hyphen, so the slug-suffix match failed and the whole URL was returned,
ending in "Document not found". Fall back to the `/doc/` segment itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scottlovegrove
scottlovegrove merged commit 78b0087 into Doist:main Oct 23, 2026
4 checks passed
doist-release-bot Bot added a commit that referenced this pull request Oct 23, 2026
## [2.1.12](v2.1.11...v2.1.12) (2026-10-23)

### Bug Fixes

* resolve document refs from browser URLs with anchors, queries or trailing paths ([#155](#155)) ([78b0087](78b0087))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.1.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

@andriykohut
andriykohut deleted the fix/doc-url-refs branch October 23, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants