Skip to content

❇️ [RTY-260032]: Handle Invalid and Valid urls #32

Open

Description

@recursivezero

Is your feature request related to a problem? Please describe.
When we pass any invalid urls then I should check and display mesage that it's invalid

Also some Server Side URLS does not have query parama but it's still valid , that also need to check

Describe the solution you'd like

instead of checking through Validators library use

from urllib.parse import urlparse

def is_valid_url(url: str) -> bool:
    try:
        parsed = urlparse(url)
        return parsed.scheme in ("http", "https") and bool(parsed.netloc)
    except Exception:
        return False

Describe alternatives you've considered
Also check for all variations of valid URLS

Additional context

Example of valid URL: https://www.mea.gov.in/Speeches-Statements.htm?dtl/40844

Activity

  1. changed the title [-]❇️ Handle Invalid and Valid urls [/-] [+]❇️ [RTY-260032]: Handle Invalid and Valid urls[/+] on Mar 3, 2026
  2. github-actions commented on Mar 3, 2026

    @github-actions

    👋 Thank you for opening this issue! We will look into it as soon as possible.

  3. recursivezero commented on Mar 3, 2026

    @recursivezero
    OwnerAuthor

    More Production Grade method

    from urllib.parse import urlparse
    import ipaddress
    
    def is_valid_url(url: str) -> bool:
        try:
            parsed = urlparse(url)
    
            # 1. Scheme check
            if parsed.scheme not in ("http", "https"):
                return False
    
            # 2. Host check
            if not parsed.netloc:
                return False
    
            # 3. Block localhost
            if parsed.hostname in ("localhost",):
                return False
    
            # 4. Optional: block private IPs
            try:
                ip = ipaddress.ip_address(parsed.hostname)
                if ip.is_private or ip.is_loopback:
                    return False
            except ValueError:
                pass  # Not an IP
    
            return True
        except Exception:
            return False
  4. recursivezero commented on Mar 8, 2026

    @recursivezero
    OwnerAuthor

    sample meta tags

      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <!-- OpenGraph Meta Tags -->
      <meta property="og:title" content="Sample Fabric Lab">
      <meta property="og:description" content="A powerful tool for visualizing fabric analysis and research">
      <meta property="og:image" content="https://app.sample.com/Sample_logo_white.png">
      <meta property="og:url" content="https://lab.sample.com">
      <meta property="og:type" content="website">
      <meta property="twitter:card" content="summary_large_image">
      <meta property="twitter:title" content="Sample Fabric Dashboard">
      <meta property="twitter:description" content="A powerful tool for fabric related operations using AI">
      <meta property="twitter:image" content="https://app.sample.com/Sample_logo_black.png">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions