diff --git a/CHANGES.md b/CHANGES.md index fa0112c0d..6a0caf5e6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 10.0.0 (Unreleased) + +- Don't automatically convert OpenStreetMap URLs into `geo:` URIs in sent messages + ## 9.1.1 (2022-05-05) - GIFs don't render inside unfurls and cause a TypeError diff --git a/src/headless/plugins/chat/model.js b/src/headless/plugins/chat/model.js index 0ce0311db..cdbcaf314 100644 --- a/src/headless/plugins/chat/model.js +++ b/src/headless/plugins/chat/model.js @@ -889,7 +889,7 @@ const ChatBox = ModelWithContact.extend({ const is_spoiler = !!this.get('composing_spoiler'); const origin_id = u.getUniqueId(); const text = attrs?.body; - const body = text ? u.httpToGeoUri(u.shortnamesToUnicode(text), _converse) : undefined; + const body = text ? u.shortnamesToUnicode(text) : undefined; attrs = Object.assign({}, attrs, { 'from': _converse.bare_jid, 'fullname': _converse.xmppstatus.get('fullname'), diff --git a/src/headless/plugins/muc/muc.js b/src/headless/plugins/muc/muc.js index 28363d8f3..5f8916df2 100644 --- a/src/headless/plugins/muc/muc.js +++ b/src/headless/plugins/muc/muc.js @@ -987,7 +987,7 @@ const ChatRoomMixin = { [text, references] = this.parseTextForReferences(attrs.body); } const origin_id = getUniqueId(); - const body = text ? u.httpToGeoUri(u.shortnamesToUnicode(text), _converse) : undefined; + const body = text ? u.shortnamesToUnicode(text) : undefined; attrs = Object.assign({}, attrs, { body, is_spoiler, diff --git a/src/headless/shared/settings/constants.js b/src/headless/shared/settings/constants.js index 6474ba41a..6a72708fe 100644 --- a/src/headless/shared/settings/constants.js +++ b/src/headless/shared/settings/constants.js @@ -13,7 +13,7 @@ * @property { String } [credentials_url] - URL from where login credentials can be fetched * @property { Boolean } [discover_connection_methods=true] * @property { RegExp } [geouri_regex] - * @property { RegExp } [geouri_replacement='https - //www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2'] + * @property { RegExp } [geouri_replacement='https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2'] * @property { String } [i18n] * @property { String } [jid] * @property { Boolean } [keepalive=true] diff --git a/src/headless/utils/core.js b/src/headless/utils/core.js index 8519b1644..ea172daf7 100644 --- a/src/headless/utils/core.js +++ b/src/headless/utils/core.js @@ -459,11 +459,6 @@ export function getUniqueId (suffix) { } } -u.httpToGeoUri = function(text) { - const replacement = 'geo:$1,$2'; - return text.replace(settings_api.get("geouri_regex"), replacement); -}; - /** * Clears the specified timeout and interval. diff --git a/src/plugins/chatview/tests/messages.js b/src/plugins/chatview/tests/messages.js index 2bae75aa4..dc903a151 100644 --- a/src/plugins/chatview/tests/messages.js +++ b/src/plugins/chatview/tests/messages.js @@ -262,6 +262,23 @@ describe("A Chat Message", function () { expect(_converse.api.chatboxes.get).not.toHaveBeenCalled(); })); + it("will render Openstreetmap-URL from geo-URI", + mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) { + + await mock.waitForRoster(_converse, 'current', 1); + const message = "geo:37.786971,-122.399677"; + const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit'; + await mock.openChatBoxFor(_converse, contact_jid); + const view = _converse.chatboxviews.get(contact_jid); + spyOn(view.model, 'sendMessage').and.callThrough(); + await mock.sendMessage(view, message); + await u.waitUntil(() => view.querySelectorAll('.chat-content .chat-msg').length, 1000); + expect(view.model.sendMessage).toHaveBeenCalled(); + const msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop(); + await u.waitUntil(() => msg.innerHTML.replace(/\/g, '') === + 'https://www.openstreetmap.org/?mlat=37.786971&mlon=-122.399677#map=18/37.786971/-122.399677'); + })); it("can be a carbon message, as defined in XEP-0280", mock.initConverse([], {}, async function (_converse) { @@ -799,6 +816,7 @@ describe("A Chat Message", function () { "Another message within 10 minutes, but from a different person"); jasmine.clock().uninstall(); + })); diff --git a/src/plugins/minimize/tests/minchats.js b/src/plugins/minimize/tests/minchats.js index 5bacf3a00..b3c8e6106 100644 --- a/src/plugins/minimize/tests/minchats.js +++ b/src/plugins/minimize/tests/minchats.js @@ -1,8 +1,6 @@ /*global mock, converse */ -const $msg = converse.env.$msg; -const u = converse.env.utils; -const sizzle = converse.env.sizzle; +const { $msg, u } = converse.env; describe("A chat message", function () { @@ -206,24 +204,6 @@ describe("A Minimized ChatBoxView's Unread Message Count", function () { expect(u.isVisible(unread_count)).toBeTruthy(); expect(unread_count.innerHTML.replace(//g, '')).toBe('1'); })); - - it("will render Openstreetmap-URL from geo-URI", - mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) { - - await mock.waitForRoster(_converse, 'current', 1); - const message = "geo:37.786971,-122.399677"; - const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit'; - await mock.openChatBoxFor(_converse, contact_jid); - const view = _converse.chatboxviews.get(contact_jid); - spyOn(view.model, 'sendMessage').and.callThrough(); - await mock.sendMessage(view, message); - await u.waitUntil(() => view.querySelectorAll('.chat-content .chat-msg').length, 1000); - expect(view.model.sendMessage).toHaveBeenCalled(); - const msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop(); - await u.waitUntil(() => msg.innerHTML.replace(/\/g, '') === - 'https://www.openstreetmap.org/?mlat=37.786971&mlon=-122.399677#map=18/37.786971/-122.399677'); - })); });