Closed cinaglia closed 9 years ago
Hi there,
This PR adds support for (possibly?) smarter context rewrites. It allows use of functions when performing String.prototype.replace() calls (see reference). A use case to explain why I've needed this recently:
String.prototype.replace()
{ host: 'www.example.com', context: '/books', rewrite: { 'page=(\\d+)': function(match, p1) { var per_page = 10; return '_offset=' + (per_page * p1); } } }
This allowed me to easily transform /books?page=1 into /books?_offset=10.
/books?page=1
/books?_offset=10
Thanks for the merge! :+1:
Thanks for the PR!
Hi there,
This PR adds support for (possibly?) smarter context rewrites. It allows use of functions when performing
String.prototype.replace()
calls (see reference). A use case to explain why I've needed this recently:This allowed me to easily transform
/books?page=1
into/books?_offset=10
.