Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ describe(`renderText`, () => {
expect(container).toMatchSnapshot();
});

it('linkifies a URL with an uppercase scheme like a lowercase one', () => {
const Markdown = renderText('see HTTPS://en.wikipedia.org/wiki/Apple');
render(Markdown);
const link = screen.getByRole('link', { name: 'en.wikipedia.org/wiki/Apple' });
expect(link).toHaveClass('str-chat__message-url-link');
expect(link).toHaveAttribute('href', 'HTTPS://en.wikipedia.org/wiki/Apple');
});

it('handles the special case where user name matches to an e-mail pattern - 1', () => {
const Markdown = renderText(
'Hello @username@email.com, is username@email.com your @primary e-mail?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';

export const Anchor = ({ children, href }: ComponentProps<'a'>) => {
const isEmail = href?.startsWith('mailto:');
const isUrl = href?.startsWith('http');
const isUrl = href?.toLowerCase().startsWith('http');

if (!href || (!isEmail && !isUrl)) return <>{children}</>;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Message/renderText/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export function escapeRegExp(text: string) {
return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
}

export const detectHttp = /(http(s?):\/\/)?(www\.)?/;
export const detectHttp = /(http(s?):\/\/)?(www\.)?/i;

// Regexes are hoisted to module scope so they are compiled once rather than on
// every call. `codeRegex`/`regexMdLinks` are only used with `String#match`
Expand Down