2

on lightning community using napili template when you are on a page with url and query parameters e.g. https://host/path1?name=value

then one of the lightning component fires e.force:navigateToURL for a relative url the query parameters from previous URL are still there, e.g. you ask to go to /path2 then the URL becomes https://host/path2?name=value

is there a way to get rid of those query parameters? I tried to strip it from window.location.href (but without reloading the page) but after the event is fired the query parameter is back.

2
  • What happens if you set the URL param to an absolute URL? Commented Dec 1, 2016 at 16:20
  • Then it would replace the URL correctly, however I do not want to do that (not unless I can find my community URL from within the component then construct absolute path)
    – Bhupendra
    Commented Dec 2, 2016 at 6:18

1 Answer 1

1

You should be able to build an absolute URL which will remove the qs params like so:

$A.get("$Site.absCoreUrl") + "/path2";

Yes it would be nice to have an attribute on the event which would not preserve qs params.

4
  • I created a relative url and set window.location.href instead, that way I do not have to know community url (as "$Site.absCoreUrl" is not he community url)
    – Bhupendra
    Commented Dec 2, 2016 at 20:04
  • will not work in Edge
    – user682217
    Commented Dec 11, 2017 at 15:16
  • @user682217 can you explain why it won't work? Commented Mar 21, 2018 at 5:02
  • 1
    @itzmukeshy7 salesforce.stackexchange.com/questions/176873/…
    – user682217
    Commented Mar 21, 2018 at 10:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .