From fdf9826b05ef12250f996ad28e77fa5a7f5da212 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 15 Jul 2020 16:16:08 -0400 Subject: [PATCH] chat: restore shortcode links to groups --- .../src/apps/chat/components/lib/message.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/apps/chat/components/lib/message.js b/pkg/interface/src/apps/chat/components/lib/message.js index 736bfb59c..1c61a9eeb 100644 --- a/pkg/interface/src/apps/chat/components/lib/message.js +++ b/pkg/interface/src/apps/chat/components/lib/message.js @@ -1,9 +1,11 @@ import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; import { OverlaySigil } from './overlay-sigil'; import { uxToHex, cite, writeText } from '../../../../lib/util'; import moment from 'moment'; import ReactMarkdown from 'react-markdown'; import RemarkDisableTokenizers from 'remark-disable-tokenizers'; +import urbitOb from 'urbit-ob'; const DISABLED_BLOCK_TOKENS = [ 'indentedCode', @@ -71,7 +73,7 @@ export class Message extends Component { ); } else if ('url' in letter) { - let imgMatch = + const imgMatch = /(jpg|img|png|gif|tiff|jpeg|JPG|IMG|PNG|TIFF|GIF|webp|WEBP|svg|SVG)$/ .exec(letter.url); const youTubeRegex = new RegExp(String(/(?:https?:\/\/(?:[a-z]+.)?)/.source) // protocol @@ -122,7 +124,6 @@ export class Message extends Component {
@@ -154,6 +155,22 @@ export class Message extends Component {

); } else { + const group = letter.text.match( + /([~][/])?(~[a-z]{3,6})(-[a-z]{6})?([/])(([a-z])+([/-])?)+/ + ); + if ((group !== null) // matched possible chatroom + && (group[2].length > 2) // possible ship? + && (urbitOb.isValidPatp(group[2]) // valid patp? + && (group[0] === letter.text))) { // entire message is room name? + return ( + + {letter.text} + + ); + } else { return (