Repository navigation
Clip a shared page when its address arrives as text beside the link. - #486
Merged
Merged
Conversation
Some apps share a page as a link and send its address again as plain text, sometimes a different host for the same article. The share extension was meant to drop the text address so the share stayed a page to clip. It only filtered `links`, and a string item is classified as text, so the address stayed in the body. Two links is not a lone web address, and the share was saved as a plain note. Drop a line that is itself a lone address when a link is present. Words beside a link still stay. Two links both offered as links still stay. The tests in CaptureIntakeTests already describe this case; they are not run in CI. Co-authored-by: git <git@cdeutsch.com>
… for. The comment over the new filter said a string item is never a `public.url` and is classified as text. That is not so: `NSItemProvider(object: NSString)` registers `public.url` beside the plain text, `kind` returns `.link` for it, and the `offeredLinks` filter already dropped it. The comment also contradicted the one at the top of `stage`. A reader trusting it would have taken `offeredLinks` for redundant and removed it. The filter is still right, for the case it really covers: a provider that registers only plain text holding an address, which is a `.text` and lands in `lines`, out of `offeredLinks`' reach. The comment now says that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two tests the lone-address filter was written for build their text item with `NSItemProvider(object: NSString)`, which registers `public.url` too and is a `.link`, so they passed before the filter existed and would pass if it were removed. A provider that registers only plain text is the case the filter changes: without it the body is both addresses and the share is not clipped. This test builds that provider and fails without the filter. Co-Authored-By: Claude Opus 5.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.
Some iOS apps share a page as a link and send its address again as text, sometimes a different host for the same article. The share extension drops that second address so the share stays a page to clip. It already did when the text item also registers
public.url, which is whatNSItemProvider(object: NSString)does:kind(of:)takes that item for a link, and theofferedLinksfilter drops it. An app whose item registers only plain text slipped past: that item is text, its address landed in the body beside the link, and two links is not a lone web address, so the share was saved as a plain note instead of being clipped.Drop a line that is itself a lone address when a link is present. Words beside a link still stay as the note's body. Two links both offered as links still stay.
testAnAddressOfferedOnlyAsPlainTextBesideTheLinkIsTheSamePagebuilds a provider that registers only UTF-8 plain text, and fails without the new line. The two tests the first commit cites (testAnAddressSharedAsTextBesideTheLinkIsTheSamePage,testTheSameLinkSharedThriceBesideAnotherAddressIsOneLink) build their text withNSItemProvider(object:), so they passed before this change too. The first commit's message gives the cause the old way; the comment in the code and the commits after it are the accurate account.swift test --package-path apps/ios/Packages/UnbentCore: 197 tests pass on the Mac. They are not run in CI.Note
Medium Risk
Changes share-extension staging rules that decide page clip vs note; behavior is user-visible but limited to iOS capture intake.
Overview
Fixes iOS share intake so a link plus a duplicate URL sent only as plain text still counts as a single page to clip, instead of a two-link note.
When a share includes a link,
CaptureStager.stagenow drops any text line that is only a lone http(s) address (lines.removeAll { CaptureNaming.isLonePageUrl($0) }), in addition to the existingofferedLinksdedupe. URLs that arrive as.text(plain-text–only providers) were previously left in the body; mixed text with a URL or two distinct link items are unchanged.Adds
testAnAddressOfferedOnlyAsPlainTextBesideTheLinkIsTheSamePage, using a provider registered only for UTF-8 plain text to assert the intake still exposes one URL andpageUrl.Reviewed by Cursor Bugbot for commit 77034de. Bugbot is set up for automated code reviews on this repo. Configure here.