Skip to content

Commit

Permalink
fix: Use another pattern for URLs (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Aug 9, 2023
1 parent d7766b7 commit 8271afd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/platform/profile/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export type LinkUrl = string
export namespace LinkUrl {
export const schema: JSONSchema<LinkUrl> = {
type: 'string',
pattern: '^((https?:)?\\/\\/)?([\\da-z.-]+)\\.([a-z.]{2,6})([\\/\\w .%()\\-]*)*\\/?$' // RFC-3986: Uniform Resource Identifier (URI): Generic Syntax // Parsing a URI Reference with a Regular Expression
pattern: '^[(http(s)?):\\/\\/(www\\.)?a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)$'
}
const regexp = new RegExp(schema.pattern!, 'i')
export const validate: ValidateFunction<LinkUrl> = (url: any): url is LinkUrl => regexp.test(url)
Expand Down
4 changes: 4 additions & 0 deletions test/platform/profiles/avatar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const AVATAR: Avatar = {
{
title: 'Discord',
url: 'https://discord.gg/decentraland'
},
{
title: 'Handle',
url: 'https://twitter.com/@decentraland'
}
],
ethAddress: '0x87956abC4078a0Cc3b89b419628b857B8AF826Ed',
Expand Down

0 comments on commit 8271afd

Please sign in to comment.