Support link highlighting on capitalized link scheme (#6056)
* Support link highlighting on capitalized link scheme * Add unit tests for urlFilter function
This commit is contained in:
parent
3f73514b98
commit
23f3fb10d2
2 changed files with 31 additions and 2 deletions
|
|
@ -90,7 +90,7 @@ export default class Markdown extends PureComponent {
|
|||
urlFilter = (url) => {
|
||||
const scheme = getScheme(url);
|
||||
|
||||
return !scheme || this.props.autolinkedUrlSchemes.indexOf(scheme) !== -1;
|
||||
return !scheme || this.props.autolinkedUrlSchemes.indexOf(scheme.toLowerCase()) !== -1;
|
||||
};
|
||||
|
||||
createRenderer = () => {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
import {shallow} from 'enzyme';
|
||||
import React from 'react';
|
||||
|
||||
import {General} from '../../mm-redux/constants';
|
||||
|
||||
import Markdown from './markdown.js';
|
||||
|
||||
describe('Markdown', () => {
|
||||
const baseProps = {
|
||||
autolinkedUrlSchemes: ['mattermost'],
|
||||
autolinkedUrlSchemes: General.DEFAULT_AUTOLINKED_URL_SCHEMES,
|
||||
baseTextStyle: {},
|
||||
mentionKeys: [{key: 'user.name'}, {key: '@channel'}, {key: '@all'}, {key: '@here'}],
|
||||
minimumHashtagLength: 3,
|
||||
|
|
@ -56,4 +58,31 @@ describe('Markdown', () => {
|
|||
<Markdown {...props}/>,
|
||||
);
|
||||
});
|
||||
|
||||
test('should return true for an uncapitalized scheme', () => {
|
||||
const url = 'https://www.mattermost.com/';
|
||||
const wrapper = shallow(
|
||||
<Markdown {...baseProps}/>,
|
||||
);
|
||||
|
||||
expect(wrapper.instance().urlFilter(url)).toBe(true);
|
||||
});
|
||||
|
||||
test('should return true for a capitalized scheme', () => {
|
||||
const url = 'Https://www.mattermost.com/';
|
||||
const wrapper = shallow(
|
||||
<Markdown {...baseProps}/>,
|
||||
);
|
||||
|
||||
expect(wrapper.instance().urlFilter(url)).toBe(true);
|
||||
});
|
||||
|
||||
test('should return false for an unknown scheme', () => {
|
||||
const url = 'unknown://www.mattermost.com/';
|
||||
const wrapper = shallow(
|
||||
<Markdown {...baseProps}/>,
|
||||
);
|
||||
|
||||
expect(wrapper.instance().urlFilter(url)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue