diff --git a/app/assets/javascripts/discourse-common/addon/lib/get-url.js b/app/assets/javascripts/discourse-common/addon/lib/get-url.js index 4a5a0f17150..fab9081c6fb 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/get-url.js +++ b/app/assets/javascripts/discourse-common/addon/lib/get-url.js @@ -41,7 +41,7 @@ export function getURLWithCDN(url) { } export function getAbsoluteURL(path) { - return baseUrl + path; + return baseUrl + withoutPrefix(path); } export function isAbsoluteURL(url) { diff --git a/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js b/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js index 4f2a337c468..25553f9fe17 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js @@ -18,11 +18,20 @@ module("Unit | Utility | get-url", function () { }); test("getAbsoluteURL", function (assert) { - setupURL(null, "https://example.com", "/forum"); + setupURL(null, "https://example.com", null); assert.strictEqual( getAbsoluteURL("/cool/path"), "https://example.com/cool/path" ); + setupURL(null, "https://example.com/forum", "/forum"); + assert.strictEqual( + getAbsoluteURL("/cool/path"), + "https://example.com/forum/cool/path" + ); + assert.strictEqual( + getAbsoluteURL("/forum/cool/path"), + "https://example.com/forum/cool/path" + ); }); test("withoutPrefix", function (assert) {