Code Monkey home page Code Monkey logo

Comments (2)

amcgregor avatar amcgregor commented on July 16, 2024

Curious! Indeed, the .resolve() method isn't applying those fragments properly.

>>> a = uri.URI("ldap://[2001:db8::7]/c=GB?objectClass?one"); a
URI('ldap://[2001:db8::7]/c=GB?objectClass?one')
>>> a / "/c=NO"
URI('ldap://[2001:db8::7]/c=NO')

While the "resolve" method does not correctly handle this case, the division operator does. It ought to correctly resolve this, however. Thanks for reporting! The second case isn't quite as simple.

>>> a = URI('sftp:example.com/etc/passwd'); a
URI('sftp:example.com/etc/passwd')  # looks right, but this is an illusion
>>> a.authority  # no host component
''

In this particular case, : is insufficient. The sftp scheme defines the following syntax:

sftp://[<user>[;fingerprint=<host-key fingerprint>]@]<host>[:<port>]/<path>/<file>

While adding the // does allow it to parse correctly, the REPR is not an identity transform. (This is also an issue.)

>>> a = URI('sftp://example.com/etc/passwd'); a
URI('sftp:example.com/etc/passwd')
>>> a.authority
'example.com'

I'll need to add sftp as a recognized URL-like protocol via https://github.com/marrow/uri/blob/develop/setup.py#L98

The last case is explained by non-URL URI treating everything after the authority part as path. For most URI schemes (e.g. URN, ISBN, etc., etc.) the part after the protocol is protocol-defined and arbitrary.

from uri.

amcgregor avatar amcgregor commented on July 16, 2024

Adding the registration of sftp = uri.scheme:URLScheme to setup.py and issuing a setup.py develop call to link it, SFTP URI now behave correctly:

>>> a = uri.URI("sftp://example.com/etc/passwd"); a
URI('sftp://example.com/etc/passwd')
>>> a.resolve("/root")
URI('sftp://example.com/root')
>>> uri.URI("sftp:example.com/etc/passwd")
URI('sftp://example.com/etc/passwd')

This'll be bundled in the next release, this week. Available in commit a8718ac. (If you are impatient, you can link this entry_point in your own application; just remember to remove your own registration of it after you update your URI version.)

from uri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.