nocodb icon indicating copy to clipboard operation
nocodb copied to clipboard

Add support for `URLENCODE` function

Open mitya57 opened this issue 2 years ago • 6 comments

Change Summary

This adds URLENCODE that percent-encodes special characters, so that column value can be safely substituted into URLs.

Change type

  • [x] feat: (new feature for the user, not a new feature for build script)
  • [ ] fix: (bug fix for the user, not a fix to a build script)
  • [ ] docs: (changes to the documentation)
  • [ ] style: (formatting, missing semi colons, etc; no production code change)
  • [ ] refactor: (refactoring production code, eg. renaming a variable)
  • [ ] test: (adding missing tests, refactoring tests; no production code change)
  • [ ] chore: (updating grunt tasks etc; no production code change)

Test/ Verification

Tested on PostgreSQL. But it should work fine on other backends, too.

mitya57 avatar Oct 30 '23 13:10 mitya57

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 30 '23 13:10 CLAassistant

You may probably just use REPLACE or REGEX_REPLACE in knex.raw to encode those special characters specified in RFC 3986.

Okay, I implemented that approach. I used the list of characters in RFC 3986 section 2.2, but I removed characters that encodeURIComponent() does not encode, and added percent sign and space.

Please review again.

mitya57 avatar Nov 10 '23 17:11 mitya57

Here is how it looks now: Screenshot

mitya57 avatar Nov 10 '23 17:11 mitya57

Rebased on top of the latest develop branch to fix the conflicts. @wingkwong, @pranavxc Please review again.

mitya57 avatar Feb 15 '24 20:02 mitya57

Fixed a stupid copy-paste error in tests, now they should pass.

mitya57 avatar Feb 16 '24 07:02 mitya57

Improved the documentation.

mitya57 avatar Feb 16 '24 08:02 mitya57

Ping please? Just rebased again.

mitya57 avatar Mar 12 '24 18:03 mitya57

Re-running the tests.

wingkwong avatar Mar 13 '24 03:03 wingkwong