From f14ce308198d5f2e4962cf9c14788cd9a878d6a6 Mon Sep 17 00:00:00 2001 From: ToyboxZach <64285391+ToyboxZach@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:19:04 -0800 Subject: [PATCH 1/2] Revert localhost change This looks like it was a change initially done for some unrelated test and the docs went back and forth with specifying wether localhost should be by default replaced with 127.0.0.1 https://github.com/meteor/meteor/commit/d056a26f0277b8e559cf32fc26be37b3638914cf It seems like the logic that eventually got placed here is completely wrong, because it could replace a ROOT_URL with 127.0.0.1 which seems very wrong. I don't see why this should be a random breaking change here. so this change reverts it back to what it was, and only replace the url if it is localhost and the code specifies that it should --- packages/meteor/url_common.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/meteor/url_common.js b/packages/meteor/url_common.js index faff1526d9..1f8c4d06b9 100644 --- a/packages/meteor/url_common.js +++ b/packages/meteor/url_common.js @@ -43,10 +43,10 @@ Meteor.absoluteUrl = function (path, options) { !/http:\/\/127\.0\.0\.1[:\/]/.test(url)) // or 127.0.0.1 url = url.replace(/^http:/, 'https:'); - var localhostRegex = /^http:\/\/localhost([:\/].*)/; - if (localhostRegex.test(url) || options.replaceLocalhost) - url = url.replace(localhostRegex, 'http://127.0.0.1$1'); - + if (options.replaceLocalhost) + { + url = url.replace( /^http:\/\/localhost([:\/].*)/, 'http://127.0.0.1$1'); + } return url; }; From 885c24818aebd5d34ec08dbfcf86f62d1590812b Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:11:15 -0300 Subject: [PATCH 2/2] updated tests back --- packages/meteor/url_tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/meteor/url_tests.js b/packages/meteor/url_tests.js index 6ef56c041b..c2e9b38bc2 100644 --- a/packages/meteor/url_tests.js +++ b/packages/meteor/url_tests.js @@ -30,14 +30,14 @@ Tinytest.add("absolute-url - basics", function(test) { rootUrl: prefix + "localhost", secure: true, }), - "http://127.0.0.1/foo" + "http://localhost/foo" ); test.equal( Meteor.absoluteUrl("foo", { rootUrl: prefix + "localhost:3000", secure: true, }), - "http://127.0.0.1:3000/foo" + "http://localhost:3000/foo" ); test.equal( Meteor.absoluteUrl("foo", {