8000 Release 1.7.0, includes Ada 2.7.2 (#43) · ada-url/ada-python@0dda1fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 0dda1fd

Browse files
authored
Release 1.7.0, includes Ada 2.7.2 (#43)
1 parent 1bae986 commit 0dda1fd

File tree

5 files changed

+78
-42
lines changed

5 files changed

+78
-42
lines changed

README.rst

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
ada-url
22
========
33

4+
This is ``ada_url``, a Python library for working with URLs based on the ``Ada`` URL
5+
parser.
46

5-
This is ``ada_url``, a Python library for parsing and joining URLs.
7+
* `Documentation <https://ada-url.readthedocs.io>`__
8+
* `Development <https://github.com/ada-url/ada-python/>`__
9+
* `Ada <https://www.ada-url.com/>`__
610

711
Installation
812
------------
@@ -16,30 +20,20 @@ Install from `PyPI <https://pypi.org/project/ada-url/>`__:
1620
Usage examples
1721
--------------
1822

19-
This package exposes a ``URL`` class that is intended to match the one described in the
20-
`WHATWG URL spec <https://url.spec.whatwg.org/#url-class>`__.
23+
Parsing URLs
24+
^^^^^^^^^^^^
2125

22-
.. code-block:: python
23-
24-
>>> from ada_url import URL
25-
>>> URL('https://example.org/path/../file.txt') as urlobj:
26-
>>> urlobj.host = 'example.com'
27-
>>> new_url = urlobj.href
28-
>>> new_url
29-
'https://example.com/file.txt'
30-
31-
It also provides high level functions for parsing and manipulating URLs. Validating
32-
a URL:
26+
The ``URL`` class is intended to match the one described in the
27+
`WHATWG URL spec <https://url.spec.whatwg.org/#url-class>`_:.
3328

3429
.. code-block:: python
3530
36-
>>> from ada_url import check_url
37-
>>> check_url('https://example.org')
38-
True
39-
>>> check_url('http://example:bougus')
40-
False
31+
>>> from ada_url import URL
32+
>>> urlobj = URL('https://example.org/path/../file.txt')
33+
>>> urlobj.href
34+
'https://example.org/path/file.txt'
4135
42-
Parsing a URL:
36+
The ``parse_url`` function returns a dictionary of all URL elements:
4337

4438
.. code-block:: python
4539
@@ -61,19 +55,59 @@ Parsing a URL:
6155
'scheme_type': <SchemeType.HTTPS: 2>
6256
}
6357
64-
Replacing URL components:
58+
Altering URLs
59+
^^^^^^^^^^^^^
60+
61+
Replacing URL components with the ``URL`` class:
6562

6663
.. code-block:: python
6764
65+
>>> from ada_url import URL
66+
>>> urlobj = URL('https://example.org/path/../file.txt')
67+
>>> urlobj.host = 'example.com'
68+
>>> urlobj.href
69+
'https://example.com/path/file.txt'
70+
71+
Replacing URL components with the ``replace_url`` function:
72+
6873
>>> from ada_url import replace_url
69-
>>> ada_url.replace_url('http://example.org:80', protocol='https:')
70-
'https://example.org/'
74+
>>> replace_url('https://example.org/path/../file.txt', host='example.com')
75+
'https://example.com/file.txt'
7176

72-
Joining a URL with a relative fragment:
77+
Search parameters
78+
^^^^^^^^^^^^^^^^^
7379

74-
>>> from ada_url import join_url
75-
>>> join_url('https://example.org/dir/child.txt', '../parent.txt')
76-
'https://example.org/parent.txt'
80+
The ``URLSearchParams`` class is intended to match the one described in the
81+
`WHATWG URL spec <https://url.spec.whatwg.org/#interface-urlsearchparams>`__.
82+
83+
.. code-block:: python
84+
85+
>>> from ada_url import URLSearchParams
86+
>>> obj = URLSearchParams('key1=value1&key2=value2')
87+
>>> list(obj.items())
88+
[('key1', 'value1'), ('key2', 'value2')]
89+
90+
The ``parse_search_params`` function returns a dictionary of search keys mapped to
91+
value lists:
92+
93+
.. code-block:: python
94+
95+
>>> from ada_url import parse_search_params
96+
>>> parse_search_params('key1=value1&key2=value2')
97+
{'key1': ['value1'], 'key2': ['value2']}
98+
99+
Internationalized domain names
100+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101+
102+
The ``idna`` class can encode and decode IDNs:
103+
104+
.. code-block:: python
105+
106+
>>> from ada_url import idna
107+
>>> idna.encode('Bücher.example')
108+
b'xn--bcher-kva.example'
109+
>>> idna.decode(b'xn--bcher-kva.example')
110+
'bücher.example'
77111
78112
WHATWG URL compliance
79113
---------------------
@@ -100,10 +134,3 @@ Contrast that with the Python standard library's ``urlib.parse`` module:
100134
'www.googlé.com'
101135
>>> parsed_url.path
102136
'/./path/../path2/'
103-
104-
More information
105-
----------------
106-
107-
* ``ada-url`` is based on the `Ada <https://www.ada-url.com/>`__ project.
108-
* A full API reference is available at `Read the Docs <https://ada-url.readthedocs.io>`__.
109-
* Source code is available at `GitHub <https://github.com/ada-url/ada-python>`__.

ada_url/ada.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2023-10-18 21:05:28 -0400. Do not edit! */
1+
/* auto-generated on 2023-10-22 19:50:50 -0400. Do not edit! */
22
/* begin file src/ada.cpp */
33
#include "ada.h"
44
/* begin file src/checkers.cpp */

ada_url/ada.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2023-10-18 21:05:28 -0400. Do not edit! */
1+
/* auto-generated on 2023-10-22 19:50:50 -0400. Do not edit! */
22
/* begin file include/ada.h */
33
/**
44
* @file ada.h
@@ -1505,8 +1505,8 @@ struct url_base {
15051505
* @return On failure, it returns zero.
15061506
* @see https://url.spec.whatwg.org/#host-parsing
15071507
*/
1508-
virtual ada_really_inline size_t
1509-
parse_port(std::string_view view, bool check_trailing_content) noexcept = 0;
1508+
virtual size_t parse_port(std::string_view view,
1509+
bool check_trailing_content) noexcept = 0;
15101510

15111511
virtual ada_really_inline size_t parse_port(std::string_view view) noexcept {
15121512
return this->parse_port(view, false);
@@ -7088,14 +7088,14 @@ url_search_params_entries_iter::next() {
70887088
#ifndef ADA_ADA_VERSION_H
70897089
#define ADA_ADA_VERSION_H
70907090

7091-
#define ADA_VERSION "2.7.1"
7091+
#define ADA_VERSION "2.7.2"
70927092

70937093
namespace ada {
70947094

70957095
enum {
70967096
ADA_VERSION_MAJOR = 2,
70977097
ADA_VERSION_MINOR = 7,
7098-
ADA_VERSION_REVISION = 1,
7098+
ADA_VERSION_REVISION = 2,
70997099
};
71007100

71017101
} // namespace ada

docs/index.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,22 @@ API Documentation
5353
.. autoclass:: URL(url, base=None)
5454
.. autoclass:: HostType()
5555
.. autoclass:: SchemeType()
56+
57+
----
58+
5659
.. autofunction:: check_url(s)
5760
.. autofunction:: join_url(base_url, s)
5861
.. autofunction:: normalize_url(s)
5962
.. autofunction:: parse_url(s, [attributes])
6063
.. autofunction:: replace_url(s, **kwargs)
64+
65+
----
66+
6167
.. autoclass:: URLSearchParams(params)
6268
.. autoclass:: parse_search_params(s)
63-
.. autoclass:: replace_search_params(s)
69+
.. autoclass:: replace_search_params(s, *args)
70+
71+
----
72+
6473
.. autoclass:: idna
6574

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = ada-url
3-
version = 1.6.0
3+
version = 1.7.0
44
description = 'URL parser and manipulator based on the WHAT WG URL standard'
55
long_description = file: README.rst
66
long_description_content_type = text/x-rst

0 commit comments

Comments
 (0)
0