repo: uritools action: commit revision: path_from: revision_from: 3d63a1e738868270a9ca820e9567b736efaa7ac2: path_to: revision_to:
commit 3d63a1e738868270a9ca820e9567b736efaa7ac2 Author: epochDate: Mon Mar 25 20:18:16 2024 -0500 added support for doing authority-less uri-absolution so it works on file URIs better diff --git a/uri-absolution b/uri-absolution
--- a/uri-absolution
+++ b/uri-absolution
@@ -1,6 +1,20 @@
#!/bin/sh
-base_uri="$1"
+if [ "$1" ];then
+ base_uri="$1"
+else
+ base_uri="file:$(pwd)/"
+fi
domain="$(printf "%s\n" "$base_uri" | uricut -d)"
+port="$(printf "%s\n" "$base_uri" | uricut -P)"
+if [ "$domain" ];then
+ if [ "$port" ];then
+ authority="//${domain}:${port}/"
+ else
+ authority="//${domain}/"
+ fi
+else
+ authority=""
+fi
scheme="$(printf "%s\n" "$base_uri" | uricut -s)"
path="$(printf "%s\n" "$base_uri" | uricut -p)"
most_of_path="$(printf "%s\n" "$base_uri" | uricut -p | rev | cut -d/ -f2- | rev)"
@@ -21,8 +35,8 @@ sed -u \
's|^<>$|'"${base_uri}"'|g;t
s|^<[ \t]*\([A-Za-z][A-Za-z+.-]*:[^ \t]*\)>|\1|g;t
s|^<[ \t]*\(#[^ \t]*\)>|'"${base_uri}"'\1|g;t
-s|^<[ \t]*\(?[^ \t]*\)>|'"$scheme"'://'"$domain"/"$path"'\1|g;t
+s|^<[ \t]*\(?[^ \t]*\)>|'"$scheme"':'"$authority""$path"'\1|g;t
s|^<[ \t]*\(//[^ \t]*\)>|'"$scheme"':\1|g;t
-s|^<[ \t]*\(/[^ \t]*\)>|'"$scheme"'://'"$domain"'\1|g;t
-s|^<[ \t]*\([^ \t]*\)>|'"$scheme"'://'"$domain"/"$most_of_path"'/\1|g;t
+s|^<[ \t]*\(/[^ \t]*\)>|'"$scheme"':'"$authority"'\1|g;t
+s|^<[ \t]*\([^ \t]*\)>|'"$scheme"':'"$authority""$most_of_path"'/\1|g;t
s|^<[ \t]*\(.*\)>|<\1> UNHANDLED|g'
-----END OF PAGE-----