diff --git a/README.md b/README.md index 13b4dad25b..4255337227 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ [![built with Meteor](https://img.shields.io/badge/Meteor-2.15-green?logo=meteor&logoColor=white)](https://meteor.com) [![built with Meteor](https://img.shields.io/badge/Meteor-3.0_beta-yellow?logo=meteor&logoColor=white)](https://guide.meteor.com/3.0-migration) +
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; }; 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", {