Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pyuri

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyuri

Better URI Handling

  • 0.3.1
  • PyPI
  • Socket score

Maintainers
1

PyURI

Build Status Coverage Status PyPI version

Better URI handling

Tested with Python 2.7 and 3.6


Install

pip install pyuri

Usage

Raw URI string parsing:

from pyuri import URI

uri = URI('http://localhost:80/path/to/file?query=value#/fragment/path')

assert uri.scheme == 'http'
assert uri.host == 'localhost'
assert uri.port == 80
assert uri.path == '/path/to/file'
assert uri.query == 'query=value'
assert uri.fragment == '/fragment/path'

Composition by parts

from pyuri import URI

uri = URI(scheme='ftp', host='localhost', port=8000, query='key=value')

assert str(uri) == 'ftp://localhost:8000?key=value'

Modification and comparison

from pyuri import URI

uri1 = URI('https://example.com:80')
uri2 = URI('https://example.com:443/new/path')

assert uri1 != uri2

uri1.port = 443
uri1.path = '/new/path'

assert str(uri1) == 'https://example.com:443/new/path'

assert uri1 == uri2

Additional helpers

from pyuri import URI

uri = URI('http://localhost:80/path/to/file?repeat=value1&repeat=value2&escape=escaped%20value#/fragment/path')

# Access query parameters as dictionary
assert uri.query_dict() == {
        'repeat': ['value1', 'value2'],
        'escape': ['escaped value']
}

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc