mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-04-15 07:45:54 +00:00
Fix post websites on q-chat
This commit is contained in:
parent
e33beb5e8a
commit
2cbaa7f0a3
@ -50,19 +50,20 @@ const extractComponents = async (url) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
url = url.replace(/^(qortal:\/\/)/, '');
|
url = url.replace(/^(qortal:\/\/)/, '');
|
||||||
|
|
||||||
if (url.startsWith('use-')) {
|
if (url.startsWith('use-')) {
|
||||||
// Handle the new 'use' format
|
// Handle the new 'use' format
|
||||||
let parts = url.split('/');
|
let parts = url.split('/');
|
||||||
const type = parts[0].split('-')[1]; // e.g., 'group' from 'use-group'
|
const type = parts[0].split('-')[1]; // e.g., 'group' from 'use-group'
|
||||||
parts.shift();
|
parts.shift();
|
||||||
const action = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., 'invite' from 'action-invite'
|
const action = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., 'invite' from 'action-invite'
|
||||||
parts.shift();
|
parts.shift();
|
||||||
const idPrefix = parts.length > 0 ? parts[0].split('-')[0] : null; // e.g., 'groupid' from 'groupid-321'
|
const idPrefix = parts.length > 0 ? parts[0].split('-')[0] : null; // e.g., 'groupid' from 'groupid-321'
|
||||||
const id = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., '321' from 'groupid-321'
|
const id = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., '321' from 'groupid-321'
|
||||||
return {
|
return {
|
||||||
type: type,
|
type: type,
|
||||||
action: action,
|
action: action,
|
||||||
[idPrefix]: id
|
[idPrefix]: id
|
||||||
}
|
}
|
||||||
} else if (url.includes('/')) {
|
} else if (url.includes('/')) {
|
||||||
let parts = url.split('/');
|
let parts = url.split('/');
|
||||||
@ -101,15 +102,13 @@ const extractComponents = async (url) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function processText(input) {
|
function processText(input) {
|
||||||
const linkRegex = /(qortal:\/\/\S+)/g;
|
const linkRegex = /(qortal:\/\/S+)/g;
|
||||||
|
|
||||||
function processNode(node) {
|
function processNode(node) {
|
||||||
if (node.nodeType === Node.TEXT_NODE) {
|
if (node.nodeType === Node.TEXT_NODE) {
|
||||||
const parts = node.textContent.split(linkRegex);
|
const parts = node.textContent.split(linkRegex);
|
||||||
|
if (parts.length > 0) {
|
||||||
if (parts.length > 1) {
|
|
||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
|
|
||||||
parts.forEach((part) => {
|
parts.forEach((part) => {
|
||||||
if (part.startsWith('qortal://')) {
|
if (part.startsWith('qortal://')) {
|
||||||
const link = document.createElement('span');
|
const link = document.createElement('span');
|
||||||
@ -2536,4 +2535,4 @@ class ChatMenu extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.customElements.define('chat-menu', ChatMenu);
|
window.customElements.define('chat-menu', ChatMenu);
|
Loading…
x
Reference in New Issue
Block a user