Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(isSIP): check if string is a SIP #2458

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aabdullaharif
Copy link

Description

This pull request addresses issue #2436 by implementing SIP URI validation in the library.

Changes Made

  • Added a new validation function for SIP URIs.
  • Included comprehensive test cases to verify the functionality of the validation.
  • Updated the documentation to reflect the new feature.

Checklist

  • [✔] PR contains only changes related; no stray files, etc.
  • [✔] README updated (where applicable)
  • [✔] Tests written (where applicable)
  • [✔] References provided in PR (where applicable)

rubiin
rubiin previously approved these changes Sep 29, 2024
src/lib/isSIP.js Outdated Show resolved Hide resolved
src/lib/isSIP.js Outdated Show resolved Hide resolved
@@ -173,6 +173,7 @@ Validator | Description
**isVAT(str, countryCode)** | check if the string is a [valid VAT number][VAT Number] if validation is available for the given country code matching [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2]. <br/><br/>`countryCode` is one of `['AL', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'EL', 'ES', 'FI', 'FR', 'GB', 'GT', 'HN', 'HR', 'HU', 'ID', 'IE', 'IL', 'IN', 'IS', 'IT', 'KZ', 'LT', 'LU', 'LV', 'MK', 'MT', 'MX', 'NG', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'RO', 'RS', 'RU', 'SA', 'SE', 'SI', 'SK', 'SM', 'SV', 'TR', 'UA', 'UY', 'UZ', 'VE']`.
**isWhitelisted(str, chars)** | check if the string consists only of characters that appear in the whitelist `chars`.
**matches(str, pattern [, modifiers])** | check if the string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`.
**isSIP(str)** | check if the string is a [SIP](https://www.ietf.org/rfc/rfc3261.txt).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this in the correct alphabetical place (after isSemVer)


/* Regular expression to match the SIP URI structure */
function isValidSipUri(uri) {
const sipUriRegex = /^sips?:([^:@]+(:[^@]*)?@)?((([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}|(\d{1,3}\.){3}\d{1,3}|\[[0-9a-fA-F:]+\])(:\d{1,5})?)(;([a-zA-Z0-9-]+=[^;?]+|lr))*?(\?[^#]*)?$/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a reference for this Regex? Are there sources for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants