Add pathname check when exec replace action.

It should ignore some paths such as '<img src="<%= elem.banner_image_url %>">' in templates file, otherwise some exceptions will thrown.