Validating, cleaning, and compactifying URLs simplified.
Project description
neturalise-link
What are the objectives?
- Remove trackers
- Remove referrers
- Identify malicious intent
- Verify URL validity
- Improve URL load speeds
How does it work?
Having imported neutralise-link you may use the neutralise function which takes a URL string as the argument.
The function is designed to return either a string URL or None. It is recommended to use the returned URL value in place of the original URL as this is the neutralised version of the URL.
By default, the function will return None in two cases:
- The link is invalid
- The link is deemed malicious
You may override the 2nd case by calling the function with the optional parameter,
safe=false.
Example Code
from neutralise_link import neutralise
def main(url: str) -> str:
"""Validate user URL input for storing."""
url = neutralise(url=url, safe=True)
if not url:
print("URL is malformed or malicious.")
print("URL is safe.")
Contributing
Prerequisites
- Have python 3.10 installed on system (e.g. using anaconda/homebrew)
Environment Setup
- Set up a virtual environment using
python -m venv venv - Activate the virtual environment using
source venv/bin/activate - Install development dependencies using
pip install -r requirements.txt
Running tests
It is important to ensure that ALL tests pass before submitting a PR.
python -m unittest discover -s tests
It is also imperative that coverage is above 90% before submitting a PR. Validate this by running:
coverage run -m tests.test_neutralise && coverage report && coverage html
Building the package
-
Navigate to root directory of the project and run:
python -m build -
Install the package found in
neutralise-link/dist/in your repo usingpip installfollowed by the relative path of the.tar.gzpackage file located in the project. For example:
pip install dist/neutralise_link-0.1.0.tar.gz
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neutralise_link-0.1.0.tar.gz.
File metadata
- Download URL: neutralise_link-0.1.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f96a637f29064263081ff66d19d65abcd40286969454e20ebf48875e98947db9
|
|
| MD5 |
351bad43d2baed1f80458997e09395b8
|
|
| BLAKE2b-256 |
39ec0132c85e351f8beab29652d639b8e2e367f3b7c6f223256e5049f4efb711
|
File details
Details for the file neutralise_link-0.1.0-py3-none-any.whl.
File metadata
- Download URL: neutralise_link-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e57ea259667e38760c985a9c0d7c528b69c1e671cadf3dc75c5e2af23497f66e
|
|
| MD5 |
2eb5f4a6aba41c08524bebd9a448a6ca
|
|
| BLAKE2b-256 |
f5a999acf0d00dc465060aca079b98728e2176c10a26fd1b58002acac68871d3
|