Skip to content

feat: Support encoding uri#3027

Merged
Marsup merged 9 commits intohapijs:v17from
HYOSITIVE:support-encoding-uri
Apr 23, 2024
Merged

feat: Support encoding uri#3027
Marsup merged 9 commits intohapijs:v17from
HYOSITIVE:support-encoding-uri

Conversation

@HYOSITIVE
Copy link
Contributor

Related Issue

About Changes

  • Added optional field encodeUri with default false in UriOptions.
  • Added encodeUri in string validation method.
    • Returns encoded URI when both convert and encodeUri flags are true.
  • Added a test case to reproduce the issue.

Result

Screenshot 2024-03-30 at 9 26 29 PM

@Marsup Marsup added this to the 17.13.0 milestone Apr 3, 2024
@Marsup Marsup self-assigned this Apr 3, 2024
@Marsup Marsup added the feature New functionality or improvement label Apr 3, 2024
@Marsup
Copy link
Collaborator

Marsup commented Apr 3, 2024

Looks like you also need to test for convert: false as true is already the default. It's also missing a bit of docs but I can do it if you don't want to. Thanks for your contribution!

@HYOSITIVE
Copy link
Contributor Author

@Marsup Thanks for the review! I will add a test case for convert: false. Besides that, could you let me know which docs did I miss? I can add those as well.

@Marsup
Copy link
Collaborator

Marsup commented Apr 8, 2024

Just missing a quick description in

joi/API.md

Lines 3084 to 3089 in 5b96852

- `options` - optional settings:
- `scheme` - Specifies one or more acceptable Schemes, should only include the scheme name. Can be an Array or String (strings are automatically escaped for use in a Regular Expression).
- `allowRelative` - Allow relative URIs. Defaults to `false`.
- `relativeOnly` - Restrict only relative URIs. Defaults to `false`.
- `allowQuerySquareBrackets` - Allows unencoded square brackets inside the query string. This is **NOT** RFC 3986 compliant but query strings like `abc[]=123&abc[]=456` are very common these days. Defaults to `false`.
- `domain` - Validate the domain component using the options specified in [`string.domain()`](#stringdomainoptions).

@HYOSITIVE
Copy link
Contributor Author

Sorry for the delay. Just updated the PR!

@Marsup
Copy link
Collaborator

Marsup commented Apr 23, 2024

I'll change it a bit before releasing for some edge cases, but this is good to go, thanks!

@Marsup Marsup merged commit 9af6f1f into hapijs:v17 Apr 23, 2024
@HYOSITIVE
Copy link
Contributor Author

Thanks, @Marsup! Please close the issue as well. I don't have a permission to do that because I'm not the one who opened it.

@Marsup
Copy link
Collaborator

Marsup commented Apr 23, 2024

It's published.

@Marsup Marsup linked an issue Apr 23, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

string().uri() not working with accented characters

2 participants