SHA256
Улучшить ссылки и прокрутку личных чатов
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { resolveShineTextLink, tokenizeShineMessageLinks } from '../js/services/shine-message-links.js';
|
||||
import { makeSolanaExplorerTxUrl, setSolanaCluster } from '../js/services/solana-rpc-gateway.js';
|
||||
|
||||
function links(text, viewMode = 'thread') {
|
||||
return tokenizeShineMessageLinks(text, { viewMode }).filter((item) => item.type !== 'text');
|
||||
@@ -43,6 +44,19 @@ test('внешние ссылки открываются отдельно и н
|
||||
assert.equal(links('http://localhost:8080/test')[0].href, 'http://localhost:8080/test');
|
||||
});
|
||||
|
||||
test('ссылка транзакции учитывает кластер Solana', () => {
|
||||
setSolanaCluster('devnet');
|
||||
assert.equal(
|
||||
makeSolanaExplorerTxUrl('sig-devnet', 'https://t2.shineup.me/solana-rpc'),
|
||||
'https://explorer.solana.com/tx/sig-devnet?cluster=devnet',
|
||||
);
|
||||
setSolanaCluster('mainnet-beta');
|
||||
assert.equal(
|
||||
makeSolanaExplorerTxUrl('sig-mainnet', 'https://shineup.me/solana-rpc'),
|
||||
'https://explorer.solana.com/tx/sig-mainnet',
|
||||
);
|
||||
});
|
||||
|
||||
test('опасные протоколы, пустые и встроенные подстроки не становятся ссылками', () => {
|
||||
assert.equal(links('javascript:alert(1) file:///etc/passwd fooSHiNE/aidar/news/34').length, 0);
|
||||
assert.equal(links('https:// www. SHiNE/').length, 0);
|
||||
|
||||
Reference in New Issue
Block a user