Skip to content

feat(Link): do not insert http:// for links from buffer#1043

Open
saxumcordis wants to merge 2 commits intomainfrom
save-no-href
Open

feat(Link): do not insert http:// for links from buffer#1043
saxumcordis wants to merge 2 commits intomainfrom
save-no-href

Conversation

@saxumcordis
Copy link
Copy Markdown
Contributor

No description provided.

@gravity-ui
Copy link
Copy Markdown

gravity-ui bot commented Apr 1, 2026

Storybook Deployed

@gravity-ui
Copy link
Copy Markdown

gravity-ui bot commented Apr 1, 2026

🎭 Playwright Report

@d3m1d0v d3m1d0v changed the title chore(links): do not insert http:// for links from buffer feat(Link): do not insert http:// for links from buffer Apr 2, 2026
const view = new EditorView(null, {state});
dispatchPasteEvent(view, {'text/plain': 'ya.ru'});
expect(view.state.doc).toMatchNode(doc(p(lnkYa('ya.ru'))));
same('[ya.ru](ya.ru)', view.state.doc);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Currently, when inserting a link, it will be inserted with the protocol. After this fix, judging by the test, there won't be any protocol.

I suggest changing it to

same('[ya.ru](http://ya.ru)', view.state.doc);

describe('linkifyRawHrefPlugin', () => {
it('uses raw hostname in href for pasted text with trailing words', () => {
const md = mdWithPlugin();
expect(md.renderInline('ya.ru dasda')).toBe('<a href="ya.ru">ya.ru</a> dasda');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, the linkifyRawHrefPlugin was added to avoid adding the protocol when the user hasn't inserted it. In my opinion, the correct approach is to always use the protocol in the link itself, as before, but not display it in the text.

So, the plugin seems unnecessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What if i paste fdqn for ssh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants