3 const moment
= require('moment');
4 const urlJoin
= require('url-join');
5 const clientEnv
= require('gitter-client-env');
8 * Generates absolute URL representing permanent link to a chat item
10 * troupeUri - URL segment identifying room (usually community-name/room-name)
12 * sent - date when the message was sent, accepted formats: JavaScript Date, moment
13 * isArchive - if true, generated link will point to room archive,
14 * otherwise link points to normal chat
16 module
.exports
= (troupeUri
, id
, sent
= null, isArchive
= false) => {
17 const basePath
= clientEnv
['basePath'];
19 const urlDate
= moment(sent
).format('YYYY/MM/DD');
20 return urlJoin(basePath
, troupeUri
, 'archives', urlDate
, `?at=${id}`);
22 return urlJoin(basePath
, troupeUri
, `?at=${id}`);