[MGNLFE-280] Uses relative url to build magnolia context object Created: 18/Jul/22 Updated: 23/Oct/23 Resolved: 27/Jul/22 |
|
| Status: | Closed |
| Project: | Magnolia Frontend Helpers |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.3.0 |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Phong Le Quoc | Assignee: | Bartosz Staryga |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Σ Remaining Estimate: | Not Specified | Remaining Estimate: | Not Specified |
| Σ Time Spent: | 1d 4.25h | Time Spent: | 4.75h |
| Σ Original Estimate: | Not Specified | Original Estimate: | Not Specified |
| Issue Links: |
|
||||||||||||||||||||||||||||||
| Sub-Tasks: |
|
||||||||||||||||||||||||||||||
| Template: |
|
||||||||||||||||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||||||||||||||||
| Task DoD: |
[X]*
Doc/release notes changes? Comment present?
[X]*
Downstream builds green?
[X]*
Solution information and context easily available?
[X]*
Tests
[X]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||||||||||||||||
| Date of First Response: | |||||||||||||||||||||||||||||||
| Epic Link: | Headless Phase 2 | ||||||||||||||||||||||||||||||
| Sprint: | DevX 15 | ||||||||||||||||||||||||||||||
| Story Points: | 1 | ||||||||||||||||||||||||||||||
| Team: | |||||||||||||||||||||||||||||||
| Description |
|
Currently, we need an absolute path to build Magnolia Context object. However, a relative path is enough. In addition, Angular Event API, React History API, and Vue Router API do not provide an absolute path. We must access low level window.location object to get the absolute path. Therefore, we should use relative path to build Magnolia Context object.
Note:
|
| Comments |
| Comment by Bartosz Staryga [ 18/Jul/22 ] |
|
If it's harder to get the full URL in some cases, then we should aim at supporting both: full URL, relative one.
function getUrl(string) {
try {
let url = 'http://valid-url.com';
if (string.startsWith('http')) {
url = string;
} else {
if (string.startsWith('/')) {
url += string
} else {
url += '/' + string
}
}
return new URL(url);
} catch (e) {
console.warn('requestUrl is not a valid URL');
return false;
}
}
|
| Comment by Bartosz Staryga [ 18/Jul/22 ] |
|
Wdyt guys? |
| Comment by Phong Le Quoc [ 19/Jul/22 ] |
|
Yeah |
| Comment by Bartosz Staryga [ 19/Jul/22 ] |
|
plequocnot really sure how your workflow works |
| Comment by Phong Le Quoc [ 21/Jul/22 ] |
|
bstaryga |
| Comment by Bartosz Staryga [ 21/Jul/22 ] |
|
Will do plequoc 👍 |