Added logic to sort between gsub for api and normal url