Rename extractLinks to extractFirstLink
Этот коммит содержится в:
@@ -70,7 +70,7 @@ export default class PostBodyAdditionalContent extends React.Component {
|
|||||||
return this.getSlackAttachment();
|
return this.getSlackAttachment();
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = Utils.extractLinks(this.props.post.message)[0];
|
const link = Utils.extractFirstLink(this.props.post.message);
|
||||||
if (!link) {
|
if (!link) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,9 +313,8 @@ export function getTimestamp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extracts links not styled by Markdown
|
// extracts links not styled by Markdown
|
||||||
export function extractLinks(text) {
|
export function extractFirstLink(text) {
|
||||||
const pattern = /(^|[\s\n]|<br\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
|
const pattern = /(^|[\s\n]|<br\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/i;
|
||||||
let links;
|
|
||||||
let inText = text;
|
let inText = text;
|
||||||
|
|
||||||
// strip out code blocks
|
// strip out code blocks
|
||||||
@@ -324,13 +323,12 @@ export function extractLinks(text) {
|
|||||||
// strip out inline markdown images
|
// strip out inline markdown images
|
||||||
inText = inText.replace(/!\[[^\]]*\]\([^\)]*\)/g, '');
|
inText = inText.replace(/!\[[^\]]*\]\([^\)]*\)/g, '');
|
||||||
|
|
||||||
links = inText.match(pattern) || [];
|
const match = pattern.exec(inText);
|
||||||
|
if (match) {
|
||||||
|
return match[0].trim();
|
||||||
|
}
|
||||||
|
|
||||||
return links.map(
|
return '';
|
||||||
(url) => {
|
|
||||||
return url.trim();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function escapeRegExp(string) {
|
export function escapeRegExp(string) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user