1

On my SP site, I'm sending some queries with URL to filter data,

https://microsoft.sharepoint.com/teams/sitename/page.aspx?queryTags=#tag1,tag2

Few months back it was working fine, but now url generating Slash (/) between ?queryTags# and tags,

https://microsoft.sharepoint.com/teams/sitename/page.aspx?queryTags=#/tag1,tag2

now filter data function is not working because of that extra /. How can I remove that slash from URL,

I can't make changes in filter date function because it's containing tons of code.

4

Replace string with javascript with replace function

 url.replace("#/", "#")
  • Can you please elaborate more? – Abhishek Pandey Feb 7 '17 at 12:42
  • 1
    But if you use JavaScript for replace then above code will replace only for first occurrence in string. So if "#/" is multiple time then it will not work. – Samir Khimani Feb 7 '17 at 13:41
  • I'm sending replace queries in filter function and this trick worked for me. – Abhishek Pandey Feb 8 '17 at 5:51
0

You can try following code to solve your problem:

var _pageUrl=document.URL;//page URL

JSRequest.EnsureSetup();
var _queryTags = JSRequest.QueryString["queryTags"]; //QueryString

_queryTags = replaceAll(_queryTags,"//",""); //Replacing '/' with empty space

//reusable function for replace all
function replaceAll(str, find, replace) {
  return str.replace(new RegExp(find, 'g'), replace);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.