Добавить текстовые ссылки SHiNE

This commit is contained in:
AidarKC
2026-10-10 15:08:06 +03:00
parent d138bd9464
commit 70fac068d0
13 changed files with 494 additions and 104 deletions
+9 -7
View File
@@ -76,20 +76,22 @@ export function makeShineChannelShortRoute({ ownerLogin = '', ownerBlockchainNam
return `${SHINE_ROUTE_SEGMENT}/${encodeRoutePart(cleanOwnerLogin)}/${encodeRoutePart(chName)}`;
}
export function makeShineChannelStreamRoute({ ownerLogin = '', ownerBlockchainName = '', channelName = '', messageBlockNumber = '' }) {
export function makeShineChannelStreamRoute({ ownerLogin = '', ownerBlockchainName = '', channelName = '', messageOrdinal = '' }) {
const base = makeShineChannelShortRoute({ ownerLogin, ownerBlockchainName, channelName });
const no = String(messageBlockNumber || '').trim();
return base && /^[0-9]+$/.test(no) ? `${base}/s/${no}` : '';
const no = String(messageOrdinal ?? '').trim();
return base && /^[1-9][0-9]*$/.test(no) && Number.isSafeInteger(Number(no)) ? `${base}/s/${no}` : '';
}
export function makeShineMessageRoute({ ownerLogin = '', messageBlockchainName = '', messageBlockNumber = '', channelName = '', channelOwnerBlockchainName = '' }) {
export function makeShineMessageRoute({ ownerLogin = '', messageBlockchainName = '', messageBlockNumber = '', messageOrdinal = '', channelName = '', channelOwnerBlockchainName = '' }) {
const msgBch = String(messageBlockchainName || '').trim();
const msgNo = String(messageBlockNumber || '').trim();
if (!msgBch || !msgNo) return '';
if (channelName) {
const ordinal = String(messageOrdinal ?? '').trim();
if (channelName && /^[1-9][0-9]*$/.test(ordinal) && Number.isSafeInteger(Number(ordinal))) {
const base = makeShineChannelShortRoute({ ownerLogin, ownerBlockchainName: channelOwnerBlockchainName || msgBch, channelName });
if (base) return `${base}/${encodeRoutePart(msgNo)}`;
if (base) return `${base}/${encodeRoutePart(ordinal)}`;
}
// Technical URLs remain valid for non-channel messages (replies, notifications, old links).
if (!msgBch || !/^[0-9]+$/.test(msgNo)) return '';
return `${SHINE_ROUTE_SEGMENT}/${encodeRoutePart(msgBch)}/${encodeRoutePart(msgNo)}`;
}