Merge pull request #12966 from ToyboxZach/patch-2

[ Meteor v3 ] - Revert localhost change
This commit is contained in:
Gabriel Grubba
2024-02-21 20:52:49 +01:00
committed by GitHub
3 changed files with 7 additions and 6 deletions

View File

@@ -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)
</div>
<hr>

View File

@@ -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;
};

View File

@@ -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", {