Fiddler/Jscript.NET :How do I append a string to specific search query?

倖福魔咒の 提交于 2019-12-24 10:46:48

问题


The problem with the below code is that it appends string at the very end of the URL

if (oSession.uriContains("search?q=")) 
    {
        var str = oSession.fullUrl;
        var sAppend = "+test1+test2+test3";
        if (!oSession.uriContains(sAppend))
        {
            oSession.fullUrl = str + sAppend;
        }
    }

So, How can I conditionally place +test1+test2+test3 right next to search?q= ?

Thank you


回答1:


What's the problem with replace function:

if (oSession.uriContains("search?q=")) 
    {
        var str = oSession.fullUrl;
        var sAppend = "+test1+test2+test3";
        if (!oSession.uriContains(sAppend))
        {
            oSession.fullUrl = str.replace( "search?q=","search?q="+sAppend);
        }
    }


来源:https://stackoverflow.com/questions/25869911/fiddler-jscript-net-how-do-i-append-a-string-to-specific-search-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!