Skip to content

Commit

Permalink
Add option to disable url shortening (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchdev authored Nov 25, 2023
1 parent 3050349 commit 16a0d6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions assets/chat/js/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const settingsdefault = new Map(
Object.entries({
schemaversion: 2,
showtime: false,
showentireurl: false,
hideflairicons: false,
profilesettings: false,
timestampformat: 'HH:mm',
Expand Down
7 changes: 6 additions & 1 deletion assets/chat/js/formatters/UrlFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,16 @@ export default class UrlFormatter {
} catch (err) {
// ignore
}

const maxUrlLength = 90;
let urlText = normalizedUrl;
if (urlText.length > maxUrlLength) {
if (
!(chat.settings.get('showentireurl') ?? false) &&
urlText.length > maxUrlLength
) {
urlText = `${urlText.slice(0, 40)}...${urlText.slice(-40)}`;
}

const extra = self.encodeUrl(decodedUrl.substring(m[0].length));
const href = `${scheme ? '' : 'http://'}${normalizedUrl}`;

Expand Down
5 changes: 5 additions & 0 deletions assets/views/embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ <h4>Messages</h4>
<input name="ignorementions" type="checkbox" /> Harsh ignore
</label>
</div>
<div class="form-group checkbox">
<label title="Show entire url in message">
<input name="showentireurl" type="checkbox" /> Show entire URL
</label>
</div>
<div class="form-group checkbox">
<label
title="Hide messages that contain links to not safe for work content"
Expand Down

0 comments on commit 16a0d6e

Please sign in to comment.