mirror of
https://github.com/thelounge/thelounge
synced 2024-11-24 21:13:06 +00:00
client: use the versions in shared/ where applicable
This commit is contained in:
parent
9d34955836
commit
e305e23c43
7 changed files with 10 additions and 96 deletions
|
@ -1,4 +0,0 @@
|
||||||
const matchFormatting =
|
|
||||||
/\x02|\x1D|\x1F|\x16|\x0F|\x11|\x1E|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?|\x04(?:[0-9a-f]{6}(?:,[0-9a-f]{6})?)?/gi;
|
|
||||||
|
|
||||||
export default (message: string) => message.replace(matchFormatting, "").trim();
|
|
|
@ -1,83 +0,0 @@
|
||||||
import LinkifyIt, {Match} from "linkify-it";
|
|
||||||
import {Part} from "./merge";
|
|
||||||
|
|
||||||
export type LinkPart = Part & {
|
|
||||||
link: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type OurMatch = Match & {
|
|
||||||
noschema?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
LinkifyIt.prototype.normalize = function normalize(match: OurMatch) {
|
|
||||||
if (!match.schema) {
|
|
||||||
match.schema = "http:";
|
|
||||||
match.url = "http://" + match.url;
|
|
||||||
match.noschema = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match.schema === "//") {
|
|
||||||
match.schema = "http:";
|
|
||||||
match.url = "http:" + match.url;
|
|
||||||
match.noschema = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match.schema === "mailto:" && !/^mailto:/i.test(match.url)) {
|
|
||||||
match.url = "mailto:" + match.url;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
import tlds from "tlds";
|
|
||||||
const linkify = LinkifyIt().tlds(tlds).tlds("onion", true);
|
|
||||||
|
|
||||||
// Known schemes to detect in text
|
|
||||||
const commonSchemes = [
|
|
||||||
"sftp",
|
|
||||||
"smb",
|
|
||||||
"file",
|
|
||||||
"irc",
|
|
||||||
"ircs",
|
|
||||||
"svn",
|
|
||||||
"git",
|
|
||||||
"steam",
|
|
||||||
"mumble",
|
|
||||||
"ts3server",
|
|
||||||
"svn+ssh",
|
|
||||||
"ssh",
|
|
||||||
"gopher",
|
|
||||||
"gemini",
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const schema of commonSchemes) {
|
|
||||||
linkify.add(schema + ":", "http:");
|
|
||||||
}
|
|
||||||
|
|
||||||
function findLinks(text: string) {
|
|
||||||
const matches = linkify.match(text) as OurMatch[];
|
|
||||||
|
|
||||||
if (!matches) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return matches.map(returnUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
function findLinksWithSchema(text: string) {
|
|
||||||
const matches = linkify.match(text) as OurMatch[];
|
|
||||||
|
|
||||||
if (!matches) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return matches.filter((url) => !url.noschema).map(returnUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
function returnUrl(url: OurMatch): LinkPart {
|
|
||||||
return {
|
|
||||||
start: url.index,
|
|
||||||
end: url.lastIndex,
|
|
||||||
link: url.url,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export {findLinks, findLinksWithSchema};
|
|
|
@ -2,7 +2,7 @@ import anyIntersection from "./anyIntersection";
|
||||||
import fill from "./fill";
|
import fill from "./fill";
|
||||||
import {ChannelPart} from "./findChannels";
|
import {ChannelPart} from "./findChannels";
|
||||||
import {EmojiPart} from "./findEmoji";
|
import {EmojiPart} from "./findEmoji";
|
||||||
import {LinkPart} from "./findLinks";
|
import {LinkPart} from "../../../../shared/linkify";
|
||||||
import {NamePart} from "./findNames";
|
import {NamePart} from "./findNames";
|
||||||
|
|
||||||
export type Part = {
|
export type Part = {
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
import {h as createElement, VNode} from "vue";
|
import {h as createElement, VNode} from "vue";
|
||||||
import parseStyle from "./ircmessageparser/parseStyle";
|
import parseStyle from "./ircmessageparser/parseStyle";
|
||||||
import findChannels, {ChannelPart} from "./ircmessageparser/findChannels";
|
import findChannels from "./ircmessageparser/findChannels";
|
||||||
import {findLinks, LinkPart} from "./ircmessageparser/findLinks";
|
import {findLinks} from "../../../shared/linkify";
|
||||||
import findEmoji, {EmojiPart} from "./ircmessageparser/findEmoji";
|
import findEmoji from "./ircmessageparser/findEmoji";
|
||||||
import findNames, {NamePart} from "./ircmessageparser/findNames";
|
import findNames from "./ircmessageparser/findNames";
|
||||||
import merge, {MergedParts, Part} from "./ircmessageparser/merge";
|
import merge, {MergedParts} from "./ircmessageparser/merge";
|
||||||
import emojiMap from "./fullnamemap.json";
|
import emojiMap from "./fullnamemap.json";
|
||||||
import LinkPreviewToggle from "../../components/LinkPreviewToggle.vue";
|
import LinkPreviewToggle from "../../components/LinkPreviewToggle.vue";
|
||||||
import LinkPreviewFileSize from "../../components/LinkPreviewFileSize.vue";
|
import LinkPreviewFileSize from "../../components/LinkPreviewFileSize.vue";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import cleanIrcMessage from "../helpers/ircmessageparser/cleanIrcMessage";
|
import {cleanIrcMessage} from "../../../shared/irc";
|
||||||
import {store} from "../store";
|
import {store} from "../store";
|
||||||
import {switchToChannel} from "../router";
|
import {switchToChannel} from "../router";
|
||||||
import {ClientChan, ClientMention, ClientMessage, NetChan} from "../types";
|
import {ClientChan, ClientMention, ClientMessage, NetChan} from "../types";
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"extends": "../tsconfig.base.json" /* Path to base configuration file to inherit from. Requires TypeScript version 2.1 or later. */,
|
"extends": "../tsconfig.base.json" /* Path to base configuration file to inherit from. Requires TypeScript version 2.1 or later. */,
|
||||||
"include": [
|
"include": [
|
||||||
"./**/*"
|
"./**/*",
|
||||||
|
"../shared"
|
||||||
] /* Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later. */,
|
] /* Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later. */,
|
||||||
"files": [
|
"files": [
|
||||||
"../package.json",
|
"../package.json",
|
||||||
|
|
|
@ -58,7 +58,7 @@ const config: webpack.Configuration = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.ts$/i,
|
test: /\.ts$/i,
|
||||||
include: [path.resolve(__dirname, "client")],
|
include: [path.resolve(__dirname, "client"), path.resolve(__dirname, "shared")],
|
||||||
exclude: path.resolve(__dirname, "node_modules"),
|
exclude: path.resolve(__dirname, "node_modules"),
|
||||||
use: {
|
use: {
|
||||||
loader: "babel-loader",
|
loader: "babel-loader",
|
||||||
|
|
Loading…
Reference in a new issue