prevent-link-loss sveltified#9873
Draft
fregante wants to merge 4 commits into
Draft
Conversation
|
This looks like an AI-generated PR, so we're preemptively closing it. If you're human and tested it, include a screenshot/video/gif of the working PR and we can reopen the PR. Don't open more PRs until this one is resolved. |
Member
Author
|
How the tables have turned 😔 |
Member
Author
sry I aven't testd yet |
There was a problem hiding this comment.
Pull request overview
This PR continues the “Svelte components” migration (#9810) by converting the prevent-link-loss feature’s UI from the prior delegate/React+dom-chef banner to a Svelte component, while keeping the underlying link-rewrite logic in the shared helper.
Changes:
- Extracted
isVulnerableToLinkLossintosource/github-helpers/prevent-link-loss.tsfor reuse. - Replaced the
prevent-link-lossfeature’s imperative banner rendering with a mounted Svelte component per textarea. - Added a new
prevent-link-loss.sveltecomponent that shows a warning banner and applies the “Fix link” rewrite.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| source/github-helpers/prevent-link-loss.ts | Adds a shared isVulnerableToLinkLoss helper for detecting when rewrites would change the text. |
| source/features/prevent-link-loss.tsx | Switches the feature from delegated event handling to observe(...) + mount(...) of a Svelte banner component. |
| source/features/prevent-link-loss.svelte | New Svelte UI for detecting vulnerable links and applying the “Fix link” replacements. |
Comment on lines
+22
to
+43
| function update(): void { | ||
| visible = isVulnerableToLinkLoss(field.value); | ||
| } | ||
|
|
||
| function fix(): void { | ||
| replaceFieldText(field, prCommitUrlRegex, preventPrCommitLinkLoss); | ||
| replaceFieldText(field, prCompareUrlRegex, preventPrCompareLinkLoss); | ||
| replaceFieldText(field, discussionUrlRegex, preventDiscussionLinkLoss); | ||
| update(); | ||
| } | ||
|
|
||
| onMount(() => { | ||
| update(); | ||
|
|
||
| field.addEventListener('input', update); | ||
| field.addEventListener('focus', update); | ||
|
|
||
| return () => { | ||
| field.removeEventListener('input', update); | ||
| field.removeEventListener('focus', update); | ||
| }; | ||
| }); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
Testing
Test content:
Test URLs:
New issue form: https://github.com/refined-github/refined-github/issues/new?assignees=&labels=bug&projects=&template=1_bug_report.yml
New comment form: refined-github/sandbox#3
New review form: https://github.com/refined-github/sandbox/pull/4/files#review-changes-modal
New review comment form: https://github.com/refined-github/sandbox/pull/4/files
Screenshot
untested