Resolve complete/partial URLs against a canonical target URL
This library was built to resolve URLs when candidates submit incompleted URLs (e.g. missing protocol, username only).
# Username only
resolve_link('underdogio', 'https://github.com/')
# https://github.com/underdogio
# Missing protocol
resolve_link('www.linkedin.com/in/toddwolfson', 'https://www.linkedin.com/')
# https://www.linkedin.com/in/toddwolfson
# Custom website
resolve_link('https://underdog.io/', 'https://www.linkedin.com/')
# https://underdog.io/
# Complete URL
resolve_link('https://github.com/underdogio', 'https://github.com/')
# https://github.com/underdogio
This is a port of our JavaScript library resolve-link.
Getting Started
Install the module with: pip install resolve_link
from resolve_link import resolve_link
resolve_link('underdogio', 'https://github.com/') # https://github.com/underdogio
Documentation
We expose resolve_link via our package resolve_link.
resolve_link(src_url, target_url)
Resolve the best variation of src_url with respect to our target_url
src_url str - URL/partial URL to be resolving from
target_url str - Canonical URL to try to match if on the same domain
Returns:
ret_val str - Completed URL formatted via urllib.parse
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Test via nosetests.
License
Copyright (c) 2015 Underdog.io
Licensed under the MIT license.
Metadata
Release files for resolve_link 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | |
|---|---|---|---|
| resolve_link-1.2.0.zip | 12.7 kB | Details | |
| resolve_link-1.2.0.tar.gz | 6.8 kB | Details |
Release files / resolve_link-1.2.0.zip
| Download URL | resolve_link-1.2.0.zip |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b611cdd75b39a86aea083e7385b0f84e45927bfd7672314c9c6825c0926f899
|
|
BLAKE2b-256 checksum How to use checksums |
7fe2017e940dfeb765da3e5ee5253aa7b2091e77c84e03c932fe572ea0d8787f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / resolve_link-1.2.0.tar.gz
| Download URL | resolve_link-1.2.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9df280f0c5833010e4f9009e677bd022a22594693a8abed1e0b0d6e2feaeaad
|
|
BLAKE2b-256 checksum How to use checksums |
9aebc51a5dafc85e3e02c0343d2ea07c4874b60e85fe7edd6e9cc6e65c184d66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |