Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Workaround for Autolinker phone problem #21515

Merged
merged 7 commits into from
May 10, 2021
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
15 changes: 12 additions & 3 deletions app/autolinker/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Autolinker from 'autolinker';

import { escapeRegExp } from '../../../lib/escapeRegExp';

export const createAutolinkerMessageRenderer = (config) =>
export const createAutolinkerMessageRenderer = ({ phone, ...config }) =>
(message) => {
if (!message.html?.trim()) {
return message;
Expand All @@ -24,8 +24,10 @@ export const createAutolinkerMessageRenderer = (config) =>
if (regexTokens && regexTokens.test(msgPart)) {
return msgPart;
}
return Autolinker.link(msgPart, {

const muttableConfig = {
...config,
phone: false,
stripTrailingSlash: false,
replaceFn: (match) => {
const token = `=!=${ Random.id() }=!=`;
Expand All @@ -41,7 +43,14 @@ export const createAutolinkerMessageRenderer = (config) =>
text: tag.toAnchorString(),
});
return token;
} });
},
};

const autolinkerMsg = Autolinker.link(msgPart, muttableConfig);

muttableConfig.phone = phone;

return phone ? Autolinker.link(autolinkerMsg, muttableConfig) : autolinkerMsg;
})
.join('');

Expand Down
12 changes: 7 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"archiver": "^3.1.1",
"arraybuffer-to-string": "^1.0.2",
"atlassian-crowd": "^0.5.0",
"autolinker": "^1.8.3",
"autolinker": "^3.14.3",
"aws-sdk": "^2.735.0",
"bad-words": "^3.0.3",
"bcrypt": "^5.0.0",
Expand Down