FIX: Build correct post and topic shareUrl (#16332)
The links returned by post.url and topic.url are relative, but contain the subdirectory. When getAbsoluteURL is called to construct the complete share URL, it adds the host and the subdirectory again. As a result the created URLs contained the subdirectory twice.
This commit is contained in:
parent
ba509a93c2
commit
ac612987ef
|
@ -41,7 +41,7 @@ export function getURLWithCDN(url) {
|
|||
}
|
||||
|
||||
export function getAbsoluteURL(path) {
|
||||
return baseUrl + path;
|
||||
return baseUrl + withoutPrefix(path);
|
||||
}
|
||||
|
||||
export function isAbsoluteURL(url) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue