Fiddler/Jscript.NET :How do I append a string to s

2019-07-30 01:49发布

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条回答
地球回转人心会变
2楼-- · 2019-07-30 02:28

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);
        }
    }
查看更多
登录 后发表回答