From f588de8fef46620956cc884a896e8ecd1a66b045 Mon Sep 17 00:00:00 2001 From: amitb0ra Date: Thu, 19 Feb 2026 20:21:57 +0000 Subject: [PATCH 1/5] refactor: rename `isURL` to `isAbsoluteURL` and update references --- .../app/custom-oauth/server/custom_oauth_server.js | 14 +++++--------- .../meteor/app/lib/server/functions/sendMessage.ts | 6 +++--- apps/meteor/app/utils/lib/getURL.ts | 4 ++-- apps/meteor/client/lib/customOAuth/CustomOAuth.ts | 4 ++-- apps/meteor/lib/utils/isAbsoluteURL.ts | 1 + apps/meteor/lib/utils/isURL.ts | 4 ---- .../services/messages/hooks/AfterSaveOEmbed.ts | 4 ++-- .../utils/{isURL.spec.ts => isAbsoluteURL.spec.ts} | 6 +++--- 8 files changed, 18 insertions(+), 25 deletions(-) create mode 100644 apps/meteor/lib/utils/isAbsoluteURL.ts delete mode 100644 apps/meteor/lib/utils/isURL.ts rename apps/meteor/tests/unit/lib/utils/{isURL.spec.ts => isAbsoluteURL.spec.ts} (77%) diff --git a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js index b9071709f2cce..fb28dea54d77a 100644 --- a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js +++ b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js @@ -10,7 +10,7 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import _ from 'underscore'; import { normalizers, fromTemplate, renameInvalidProperties } from './transform_helpers'; -import { isURL } from '../../../lib/utils/isURL'; +import { isAbsoluteURL } from '../../../lib/utils/isAbsoluteURL'; import { client } from '../../../server/database/utils'; import { callbacks } from '../../../server/lib/callbacks'; import { saveUserIdentity } from '../../lib/server/functions/saveUserIdentity'; @@ -93,15 +93,11 @@ export class CustomOAuth { this.identityTokenSentVia = this.tokenSentVia; } - if (!isURL(this.tokenPath)) { - this.tokenPath = this.serverURL + this.tokenPath; - } - - if (!isURL(this.identityPath)) { - this.identityPath = this.serverURL + this.identityPath; - } + if (!isAbsoluteURL(this.tokenPath)) { + this.tokenPath = this.serverURL + this.tokenPath; + } - if (Match.test(options.addAutopublishFields, Object)) { + if (!isAbsoluteURL(this.identityPath)) { Accounts.addAutopublishFields(options.addAutopublishFields); } } diff --git a/apps/meteor/app/lib/server/functions/sendMessage.ts b/apps/meteor/app/lib/server/functions/sendMessage.ts index 036004aad5a7c..95b920f7e743f 100644 --- a/apps/meteor/app/lib/server/functions/sendMessage.ts +++ b/apps/meteor/app/lib/server/functions/sendMessage.ts @@ -6,7 +6,7 @@ import { Match, check } from 'meteor/check'; import { parseUrlsInMessage } from './parseUrlsInMessage'; import { isRelativeURL } from '../../../../lib/utils/isRelativeURL'; -import { isURL } from '../../../../lib/utils/isURL'; +import { isAbsoluteURL } from '../../../../lib/utils/isAbsoluteURL'; import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; import { FileUpload } from '../../../file-upload/server'; import { settings } from '../../../settings/server'; @@ -33,7 +33,7 @@ type SendMessageOptions = { const validFullURLParam = Match.Where((value) => { check(value, String); - if (!isURL(value) && !value.startsWith(FileUpload.getPath())) { + if (!isAbsoluteURL(value) && !value.startsWith(FileUpload.getPath())) { throw new Error('Invalid href value provided'); } @@ -47,7 +47,7 @@ const validFullURLParam = Match.Where((value) => { const validPartialURLParam = Match.Where((value) => { check(value, String); - if (!isRelativeURL(value) && !isURL(value) && !value.startsWith(FileUpload.getPath())) { + if (!isRelativeURL(value) && !isAbsoluteURL(value) && !value.startsWith(FileUpload.getPath())) { throw new Error('Invalid href value provided'); } diff --git a/apps/meteor/app/utils/lib/getURL.ts b/apps/meteor/app/utils/lib/getURL.ts index 3d757abb6c83c..0eeb31665705d 100644 --- a/apps/meteor/app/utils/lib/getURL.ts +++ b/apps/meteor/app/utils/lib/getURL.ts @@ -1,6 +1,6 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; -import { isURL } from '../../../lib/utils/isURL'; +import { isAbsoluteURL } from '../../../lib/utils/isAbsoluteURL'; import { ltrim, rtrim, trim } from '../../../lib/utils/stringUtils'; function getCloudUrl( @@ -41,7 +41,7 @@ export const _getURL = ( { cdn, full, cloud, cloud_route, cloud_params, _cdn_prefix, _root_url_path_prefix, _site_url }: Record, deeplinkUrl?: string, ): string => { - if (isURL(path)) { + if (isAbsoluteURL(path)) { return path; } diff --git a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts index 8ac31adc0a5ce..3becf6e999aca 100644 --- a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts +++ b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts @@ -5,7 +5,7 @@ import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; import { OAuth } from 'meteor/oauth'; -import { isURL } from '../../../lib/utils/isURL'; +import { isAbsoluteURL } from '../../../lib/utils/isAbsoluteURL'; import type { IOAuthProvider } from '../../definitions/IOAuthProvider'; import { createOAuthTotpLoginMethod } from '../../meteor/login/oauth'; import { overrideLoginMethod, type LoginCallback } from '../2fa/overrideLoginMethod'; @@ -48,7 +48,7 @@ export class CustomOAuth implements IOAuth this.scope = options.scope ?? 'openid'; this.responseType = options.responseType || 'code'; - if (!isURL(this.authorizePath)) { + if (!isAbsoluteURL(this.authorizePath)) { this.authorizePath = this.serverURL + this.authorizePath; } } diff --git a/apps/meteor/lib/utils/isAbsoluteURL.ts b/apps/meteor/lib/utils/isAbsoluteURL.ts new file mode 100644 index 0000000000000..93fce2d0fa45b --- /dev/null +++ b/apps/meteor/lib/utils/isAbsoluteURL.ts @@ -0,0 +1 @@ +export const isAbsoluteURL = (str: string): boolean => /^(https?:\/\/|data:)/.test(str); diff --git a/apps/meteor/lib/utils/isURL.ts b/apps/meteor/lib/utils/isURL.ts deleted file mode 100644 index ec245e9fdc67f..0000000000000 --- a/apps/meteor/lib/utils/isURL.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * @todo rename it as isAbsoluteURL - */ -export const isURL = (str: string): boolean => /^(https?:\/\/|data:)/.test(str); diff --git a/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts b/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts index eba201a70a20d..7820b419587f2 100644 --- a/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts +++ b/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts @@ -18,7 +18,7 @@ import { camelCase } from 'lodash'; import { settings } from '../../../../app/settings/server'; import { Info } from '../../../../app/utils/rocketchat.info'; -import { isURL } from '../../../../lib/utils/isURL'; +import { isAbsoluteURL } from '../../../../lib/utils/isAbsoluteURL'; import { afterParseUrlContent, beforeGetUrlContent } from '../lib/oembed/providers'; const MAX_EXTERNAL_URL_PREVIEWS = 5; @@ -182,7 +182,7 @@ const getUrlContent = async (urlObj: URL, redirectCount = 5): Promise { const parsedUrlObject: MessageUrl = { url, meta: {} }; let foundMeta = false; - if (!isURL(url)) { + if (!isAbsoluteURL(url)) { return { urlPreview: parsedUrlObject, foundMeta }; } diff --git a/apps/meteor/tests/unit/lib/utils/isURL.spec.ts b/apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts similarity index 77% rename from apps/meteor/tests/unit/lib/utils/isURL.spec.ts rename to apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts index fd314b501468c..06e38d0d0b56c 100644 --- a/apps/meteor/tests/unit/lib/utils/isURL.spec.ts +++ b/apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { isURL } from '../../../../lib/utils/isURL'; +import { isAbsoluteURL } from '../../../../lib/utils/isAbsoluteURL'; -describe('isURL', () => { +describe('isAbsoluteURL', () => { const testCases = [ ['/', false], ['test', false], @@ -15,7 +15,7 @@ describe('isURL', () => { testCases.forEach(([parameter, expectedResult]) => { it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => { - const result = isURL(parameter); + const result = isAbsoluteURL(parameter); expect(result).to.be.equal(expectedResult); }); }); From 9de4104a86deb6555934ffe4e3535b926fbdb0aa Mon Sep 17 00:00:00 2001 From: amitb0ra Date: Thu, 19 Feb 2026 20:22:23 +0000 Subject: [PATCH 2/5] refactor: add `isAbsoluteURL` function and corresponding tests --- apps/meteor/lib/utils/isURL.ts | 1 + .../meteor/tests/unit/lib/utils/isURL.spec.ts | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 apps/meteor/lib/utils/isURL.ts create mode 100644 apps/meteor/tests/unit/lib/utils/isURL.spec.ts diff --git a/apps/meteor/lib/utils/isURL.ts b/apps/meteor/lib/utils/isURL.ts new file mode 100644 index 0000000000000..93fce2d0fa45b --- /dev/null +++ b/apps/meteor/lib/utils/isURL.ts @@ -0,0 +1 @@ +export const isAbsoluteURL = (str: string): boolean => /^(https?:\/\/|data:)/.test(str); diff --git a/apps/meteor/tests/unit/lib/utils/isURL.spec.ts b/apps/meteor/tests/unit/lib/utils/isURL.spec.ts new file mode 100644 index 0000000000000..1e81a1bb77687 --- /dev/null +++ b/apps/meteor/tests/unit/lib/utils/isURL.spec.ts @@ -0,0 +1,22 @@ +import { expect } from 'chai'; + +import { isAbsoluteURL } from '../../../../lib/utils/isURL'; + +describe('isAbsoluteURL', () => { + const testCases = [ + ['/', false], + ['test', false], + ['test/test', false], + ['.', false], + ['./test', false], + ['https://rocket.chat', true], + ['data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', true], + ] as const; + + testCases.forEach(([parameter, expectedResult]) => { + it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => { + const result = isAbsoluteURL(parameter); + expect(result).to.be.equal(expectedResult); + }); + }); +}); From 0bb8728ee12db6c1b9feba3fe3ada2dbaa840870 Mon Sep 17 00:00:00 2001 From: Amit Bora Date: Fri, 20 Feb 2026 02:10:20 +0530 Subject: [PATCH 3/5] Update apps/meteor/app/custom-oauth/server/custom_oauth_server.js Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- .../meteor/app/custom-oauth/server/custom_oauth_server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js index fb28dea54d77a..921626dd439a4 100644 --- a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js +++ b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js @@ -98,8 +98,12 @@ export class CustomOAuth { } if (!isAbsoluteURL(this.identityPath)) { - Accounts.addAutopublishFields(options.addAutopublishFields); - } + this.identityPath = this.serverURL + this.identityPath; + } + + if (Match.test(options.addAutopublishFields, Object)) { + Accounts.addAutopublishFields(options.addAutopublishFields); + } } async getAccessToken(query) { From 93a2d0a8b7010ebd11c1e4b013ac3a1c0e60167a Mon Sep 17 00:00:00 2001 From: amitb0ra Date: Thu, 19 Feb 2026 20:41:28 +0000 Subject: [PATCH 4/5] refactor: migrate `isAbsoluteURL` to `@rocket.chat/tools` and update imports --- .../server/custom_oauth_server.js | 2 +- .../app/lib/server/functions/sendMessage.ts | 2 +- apps/meteor/app/utils/lib/getURL.ts | 3 +-- .../client/lib/customOAuth/CustomOAuth.ts | 2 +- apps/meteor/lib/utils/isURL.ts | 1 - .../messages/hooks/AfterSaveOEmbed.ts | 2 +- .../unit/lib/utils/isAbsoluteURL.spec.ts | 22 --------------- .../meteor/tests/unit/lib/utils/isURL.spec.ts | 22 --------------- packages/tools/src/index.ts | 1 + packages/tools/src/isAbsoluteURL.spec.ts | 27 +++++++++++++++++++ .../tools/src}/isAbsoluteURL.ts | 0 11 files changed, 33 insertions(+), 51 deletions(-) delete mode 100644 apps/meteor/lib/utils/isURL.ts delete mode 100644 apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts delete mode 100644 apps/meteor/tests/unit/lib/utils/isURL.spec.ts create mode 100644 packages/tools/src/isAbsoluteURL.spec.ts rename {apps/meteor/lib/utils => packages/tools/src}/isAbsoluteURL.ts (100%) diff --git a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js index 921626dd439a4..4d2e12a3ad21f 100644 --- a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js +++ b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js @@ -10,7 +10,7 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import _ from 'underscore'; import { normalizers, fromTemplate, renameInvalidProperties } from './transform_helpers'; -import { isAbsoluteURL } from '../../../lib/utils/isAbsoluteURL'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { client } from '../../../server/database/utils'; import { callbacks } from '../../../server/lib/callbacks'; import { saveUserIdentity } from '../../lib/server/functions/saveUserIdentity'; diff --git a/apps/meteor/app/lib/server/functions/sendMessage.ts b/apps/meteor/app/lib/server/functions/sendMessage.ts index 95b920f7e743f..1ad335740ae94 100644 --- a/apps/meteor/app/lib/server/functions/sendMessage.ts +++ b/apps/meteor/app/lib/server/functions/sendMessage.ts @@ -6,7 +6,7 @@ import { Match, check } from 'meteor/check'; import { parseUrlsInMessage } from './parseUrlsInMessage'; import { isRelativeURL } from '../../../../lib/utils/isRelativeURL'; -import { isAbsoluteURL } from '../../../../lib/utils/isAbsoluteURL'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; import { FileUpload } from '../../../file-upload/server'; import { settings } from '../../../settings/server'; diff --git a/apps/meteor/app/utils/lib/getURL.ts b/apps/meteor/app/utils/lib/getURL.ts index 0eeb31665705d..9cd50b52f760b 100644 --- a/apps/meteor/app/utils/lib/getURL.ts +++ b/apps/meteor/app/utils/lib/getURL.ts @@ -1,6 +1,5 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; - -import { isAbsoluteURL } from '../../../lib/utils/isAbsoluteURL'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { ltrim, rtrim, trim } from '../../../lib/utils/stringUtils'; function getCloudUrl( diff --git a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts index 3becf6e999aca..5d52eacdba1fc 100644 --- a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts +++ b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts @@ -5,7 +5,7 @@ import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; import { OAuth } from 'meteor/oauth'; -import { isAbsoluteURL } from '../../../lib/utils/isAbsoluteURL'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import type { IOAuthProvider } from '../../definitions/IOAuthProvider'; import { createOAuthTotpLoginMethod } from '../../meteor/login/oauth'; import { overrideLoginMethod, type LoginCallback } from '../2fa/overrideLoginMethod'; diff --git a/apps/meteor/lib/utils/isURL.ts b/apps/meteor/lib/utils/isURL.ts deleted file mode 100644 index 93fce2d0fa45b..0000000000000 --- a/apps/meteor/lib/utils/isURL.ts +++ /dev/null @@ -1 +0,0 @@ -export const isAbsoluteURL = (str: string): boolean => /^(https?:\/\/|data:)/.test(str); diff --git a/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts b/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts index 7820b419587f2..285384d5afae0 100644 --- a/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts +++ b/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts @@ -18,7 +18,7 @@ import { camelCase } from 'lodash'; import { settings } from '../../../../app/settings/server'; import { Info } from '../../../../app/utils/rocketchat.info'; -import { isAbsoluteURL } from '../../../../lib/utils/isAbsoluteURL'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { afterParseUrlContent, beforeGetUrlContent } from '../lib/oembed/providers'; const MAX_EXTERNAL_URL_PREVIEWS = 5; diff --git a/apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts b/apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts deleted file mode 100644 index 06e38d0d0b56c..0000000000000 --- a/apps/meteor/tests/unit/lib/utils/isAbsoluteURL.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { expect } from 'chai'; - -import { isAbsoluteURL } from '../../../../lib/utils/isAbsoluteURL'; - -describe('isAbsoluteURL', () => { - const testCases = [ - ['/', false], - ['test', false], - ['test/test', false], - ['.', false], - ['./test', false], - ['https://rocket.chat', true], - ['data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', true], - ] as const; - - testCases.forEach(([parameter, expectedResult]) => { - it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => { - const result = isAbsoluteURL(parameter); - expect(result).to.be.equal(expectedResult); - }); - }); -}); diff --git a/apps/meteor/tests/unit/lib/utils/isURL.spec.ts b/apps/meteor/tests/unit/lib/utils/isURL.spec.ts deleted file mode 100644 index 1e81a1bb77687..0000000000000 --- a/apps/meteor/tests/unit/lib/utils/isURL.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { expect } from 'chai'; - -import { isAbsoluteURL } from '../../../../lib/utils/isURL'; - -describe('isAbsoluteURL', () => { - const testCases = [ - ['/', false], - ['test', false], - ['test/test', false], - ['.', false], - ['./test', false], - ['https://rocket.chat', true], - ['data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', true], - ] as const; - - testCases.forEach(([parameter, expectedResult]) => { - it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => { - const result = isAbsoluteURL(parameter); - expect(result).to.be.equal(expectedResult); - }); - }); -}); diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index 7889c9caf5caa..ca7406644c65f 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -16,3 +16,4 @@ export * from './validateEmail'; export * from './truncateString'; export * from './isTruthy'; export * from './getHeader'; +export * from './isAbsoluteURL'; diff --git a/packages/tools/src/isAbsoluteURL.spec.ts b/packages/tools/src/isAbsoluteURL.spec.ts new file mode 100644 index 0000000000000..50b656a2433e9 --- /dev/null +++ b/packages/tools/src/isAbsoluteURL.spec.ts @@ -0,0 +1,27 @@ +import { isAbsoluteURL } from './isAbsoluteURL'; + +describe('isAbsoluteURL', () => { + test.each([ + ['/', false], + ['test', false], + ['test/test', false], + ['.', false], + ['./test', false], + ['/absolute/path', false], + ['relative/path?query=1', false], + ['ftp://example.com', false], + ])('should return false for non-absolute URL %# (%s)', (input, expected) => { + expect(isAbsoluteURL(input)).toBe(expected); + }); + + test.each([ + ['https://rocket.chat', true], + ['http://rocket.chat', true], + ['https://example.com/path?query=1#hash', true], + ['http://localhost:3000', true], + ['data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', true], + ['data:text/plain;charset=utf-8,Hello', true], + ])('should return true for absolute URL %# (%s)', (input, expected) => { + expect(isAbsoluteURL(input)).toBe(expected); + }); +}); diff --git a/apps/meteor/lib/utils/isAbsoluteURL.ts b/packages/tools/src/isAbsoluteURL.ts similarity index 100% rename from apps/meteor/lib/utils/isAbsoluteURL.ts rename to packages/tools/src/isAbsoluteURL.ts From e45c1438e22c136d64b35825e7a3ac49528c147e Mon Sep 17 00:00:00 2001 From: amitb0ra Date: Thu, 19 Feb 2026 22:39:27 +0000 Subject: [PATCH 5/5] refactor: remove duplicate imports of `isAbsoluteURL` and update usage across multiple files --- .../server/custom_oauth_server.js | 20 +++++++++---------- .../app/lib/server/functions/sendMessage.ts | 2 +- apps/meteor/app/utils/lib/getURL.ts | 1 + .../client/lib/customOAuth/CustomOAuth.ts | 2 +- .../messages/hooks/AfterSaveOEmbed.ts | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js index 4d2e12a3ad21f..34bd0b8efe285 100644 --- a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js +++ b/apps/meteor/app/custom-oauth/server/custom_oauth_server.js @@ -2,6 +2,7 @@ import { LDAP } from '@rocket.chat/core-services'; import { Logger } from '@rocket.chat/logger'; import { Users } from '@rocket.chat/models'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { Accounts } from 'meteor/accounts-base'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; @@ -10,7 +11,6 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import _ from 'underscore'; import { normalizers, fromTemplate, renameInvalidProperties } from './transform_helpers'; -import { isAbsoluteURL } from '@rocket.chat/tools'; import { client } from '../../../server/database/utils'; import { callbacks } from '../../../server/lib/callbacks'; import { saveUserIdentity } from '../../lib/server/functions/saveUserIdentity'; @@ -93,17 +93,17 @@ export class CustomOAuth { this.identityTokenSentVia = this.tokenSentVia; } - if (!isAbsoluteURL(this.tokenPath)) { - this.tokenPath = this.serverURL + this.tokenPath; - } + if (!isAbsoluteURL(this.tokenPath)) { + this.tokenPath = this.serverURL + this.tokenPath; + } - if (!isAbsoluteURL(this.identityPath)) { - this.identityPath = this.serverURL + this.identityPath; - } + if (!isAbsoluteURL(this.identityPath)) { + this.identityPath = this.serverURL + this.identityPath; + } - if (Match.test(options.addAutopublishFields, Object)) { - Accounts.addAutopublishFields(options.addAutopublishFields); - } + if (Match.test(options.addAutopublishFields, Object)) { + Accounts.addAutopublishFields(options.addAutopublishFields); + } } async getAccessToken(query) { diff --git a/apps/meteor/app/lib/server/functions/sendMessage.ts b/apps/meteor/app/lib/server/functions/sendMessage.ts index 1ad335740ae94..8f713511562b9 100644 --- a/apps/meteor/app/lib/server/functions/sendMessage.ts +++ b/apps/meteor/app/lib/server/functions/sendMessage.ts @@ -2,11 +2,11 @@ import { AppEvents, Apps } from '@rocket.chat/apps'; import { Message } from '@rocket.chat/core-services'; import type { IMessage, IRoom } from '@rocket.chat/core-typings'; import { Messages } from '@rocket.chat/models'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { Match, check } from 'meteor/check'; import { parseUrlsInMessage } from './parseUrlsInMessage'; import { isRelativeURL } from '../../../../lib/utils/isRelativeURL'; -import { isAbsoluteURL } from '@rocket.chat/tools'; import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; import { FileUpload } from '../../../file-upload/server'; import { settings } from '../../../settings/server'; diff --git a/apps/meteor/app/utils/lib/getURL.ts b/apps/meteor/app/utils/lib/getURL.ts index 9cd50b52f760b..ed510767311da 100644 --- a/apps/meteor/app/utils/lib/getURL.ts +++ b/apps/meteor/app/utils/lib/getURL.ts @@ -1,5 +1,6 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; import { isAbsoluteURL } from '@rocket.chat/tools'; + import { ltrim, rtrim, trim } from '../../../lib/utils/stringUtils'; function getCloudUrl( diff --git a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts index 5d52eacdba1fc..69883efa401f8 100644 --- a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts +++ b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts @@ -1,11 +1,11 @@ import type { OAuthConfiguration, OauthConfig } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { capitalize } from '@rocket.chat/string-helpers'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; import { OAuth } from 'meteor/oauth'; -import { isAbsoluteURL } from '@rocket.chat/tools'; import type { IOAuthProvider } from '../../definitions/IOAuthProvider'; import { createOAuthTotpLoginMethod } from '../../meteor/login/oauth'; import { overrideLoginMethod, type LoginCallback } from '../2fa/overrideLoginMethod'; diff --git a/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts b/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts index 285384d5afae0..2c1144d1f6904 100644 --- a/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts +++ b/apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts @@ -10,6 +10,7 @@ import { isOEmbedUrlWithMetadata } from '@rocket.chat/core-typings'; import { Logger } from '@rocket.chat/logger'; import { OEmbedCache, Messages } from '@rocket.chat/models'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; +import { isAbsoluteURL } from '@rocket.chat/tools'; import he from 'he'; import iconv from 'iconv-lite'; import ipRangeCheck from 'ip-range-check'; @@ -18,7 +19,6 @@ import { camelCase } from 'lodash'; import { settings } from '../../../../app/settings/server'; import { Info } from '../../../../app/utils/rocketchat.info'; -import { isAbsoluteURL } from '@rocket.chat/tools'; import { afterParseUrlContent, beforeGetUrlContent } from '../lib/oembed/providers'; const MAX_EXTERNAL_URL_PREVIEWS = 5;