feat: Rename parse_uri.sh to uri.sh
This commit is contained in:
parent
efd493bc3f
commit
68b4def813
2
Makefile
2
Makefile
@ -15,7 +15,7 @@ help:
|
||||
@echo 'tests run tests from $(tests_dir)'
|
||||
@echo 'docs build documentation from $(docs_dir)'
|
||||
@echo
|
||||
@echo See README.rst for more info
|
||||
@echo See README.rst for more info.
|
||||
|
||||
tests:
|
||||
# See bats(1), https://bats-core.readthedocs.io/en/latest/index.html
|
||||
|
@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# parse_uri.sh - URI parser function (mostly compatible with RFC3986).
|
||||
# uri.sh - URI processing functions.
|
||||
# Copyright (c) 2022 ge <https://nixhacks.net/>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@ -18,7 +18,8 @@
|
||||
|
||||
parse_uri() {
|
||||
# Universal URI parser. There is fantastic shitcode, but it works.
|
||||
# Refer RFC3986: https://datatracker.ietf.org/doc/html/rfc3986
|
||||
# This parser is mostly compatible with RFC3986:
|
||||
# https://datatracker.ietf.org/doc/html/rfc3986
|
||||
# URL-encoded passwords supported.
|
||||
#
|
||||
# Usage: parse_uri URI
|
@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env bats
|
||||
|
||||
# lib/parse_uri.sh tests.
|
||||
# parse_uri() from lib/uri.sh tests.
|
||||
# See: https://bats-core.readthedocs.io/en/latest/index.html
|
||||
|
||||
setup() {
|
||||
@ -16,7 +16,7 @@ setup() {
|
||||
# ------------------------------ #
|
||||
|
||||
@test "Test file:/" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'file:/'
|
||||
[ "$scheme" == 'file' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -29,7 +29,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test file:/path" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'file:/path'
|
||||
[ "$scheme" == 'file' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -42,7 +42,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test file:///" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'file:///'
|
||||
[ "$scheme" == 'file' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -55,7 +55,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test sqlite:///path" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'sqlite:///path'
|
||||
[ "$scheme" == 'sqlite' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -68,7 +68,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test file://host" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'file://host'
|
||||
[ "$scheme" == 'file' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -81,7 +81,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test s3://host/path" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 's3://host/path'
|
||||
[ "$scheme" == 's3' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -94,7 +94,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test dav://user@host/" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'dav://user@host/'
|
||||
[ "$scheme" == 'dav' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -107,7 +107,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test dav://user:p%40%24%24w0rD@host/path/" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'dav://user:p%40%24%24w0rD@host/path/'
|
||||
[ "$scheme" == 'dav' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -120,7 +120,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test rsync://user:password@host:~/backups" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'rsync://user:password@host:~/backups'
|
||||
[ "$scheme" == 'rsync' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -133,7 +133,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test postgres://user:password@host:5432" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'postgres://user:password@host:5432'
|
||||
[ "$scheme" == 'postgres' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -146,7 +146,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test http://user:password@host:port/path?q=val" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'scheme://user:password@host:123/path?q=val'
|
||||
[ "$scheme" == 'scheme' ]
|
||||
[ "$hostname" == 'host' ]
|
||||
@ -159,7 +159,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test ftp://user:%24t%D0%AFo%7C%5C%7C6@[fe80::5054:ff:fe24:382]:2021/srv/" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'ftp://user:%24t%D0%AFo%7C%5C%7C6@[fe80::5054:ff:fe24:382]:2021/srv/'
|
||||
[ "$scheme" == 'ftp' ]
|
||||
[ "$hostname" == '[fe80::5054:ff:fe24:382]' ]
|
||||
@ -176,7 +176,7 @@ setup() {
|
||||
# ------------------------------ #
|
||||
|
||||
@test "Test https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top'
|
||||
[ "$scheme" == 'https' ]
|
||||
[ "$hostname" == 'www.example.com' ]
|
||||
@ -189,7 +189,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test ldap://[2001:db8::7]/c=GB?objectClass?one" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'ldap://[2001:db8::7]/c=GB?objectClass?one'
|
||||
[ "$scheme" == 'ldap' ]
|
||||
[ "$hostname" == '[2001:db8::7]' ]
|
||||
@ -202,7 +202,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test mailto:John.Doe@example.com" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'mailto:John.Doe@example.com'
|
||||
[ "$scheme" == 'mailto' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -215,7 +215,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test news:comp.infosystems.www.servers.unix" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'news:comp.infosystems.www.servers.unix'
|
||||
[ "$scheme" == 'news' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -228,7 +228,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test tel:+1-816-555-1212" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'tel:+1-816-555-1212'
|
||||
[ "$scheme" == 'tel' ]
|
||||
[ "$hostname" == '' ]
|
||||
@ -242,7 +242,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test telnet://192.0.2.16:80/" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'telnet://192.0.2.16:80/'
|
||||
[ "$scheme" == 'telnet' ]
|
||||
[ "$hostname" == '192.0.2.16' ]
|
||||
@ -255,7 +255,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "Test urn:oasis:names:specification:docbook:dtd:xml:4.1.2" {
|
||||
. parse_uri.sh
|
||||
. uri.sh
|
||||
parse_uri 'urn:oasis:names:specification:docbook:dtd:xml:4.1.2'
|
||||
[ "$scheme" == 'urn' ]
|
||||
[ "$hostname" == '' ]
|
||||
|
Loading…
Reference in New Issue
Block a user