Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Replacing a URL in my output

Not applicable

HI,

I need help finding the right way to replace a URL that I do not want to pass in my output.

I would like to replace the <link> value (http://feed.google.com) with (http://feed.placeholder.com) how do i do this in a policy? or should i do this with a script?

<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0">

<channel>

<title>New E...</title> <link>http://feed.google.com</link> <description>Syndicated Feed of New...</description>

Solved Solved
0 6 2,813
1 ACCEPTED SOLUTION

Not applicable

Thanks guys!

Here's what I ended up going with. Hope this helps someone else here!

var env = context.getVariable('environment.name'); 

if (env == "production") {

	targetUrl = "http://production.apigee.net/"; 
} 
else if (env == "staging") {   

	targetUrl = "http://staging.apigee.net/"; 
} 

else if (env == "development") {
	targetUrl = "http://development.apigee.net/"; 
} 
str = targetUrl + "syndication/"; 
var rc = context.getVariable("response.content");
var newstr = rc.replace("http://feed.test.com/folder", str);
context.setVariable("response.content", newstr);

View solution in original post

6 REPLIES 6