diff options
Diffstat (limited to 'uri-absolution')
-rwxr-xr-x | uri-absolution | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/uri-absolution b/uri-absolution new file mode 100755 index 0000000..a1eb6c1 --- /dev/null +++ b/uri-absolution @@ -0,0 +1,25 @@ +#!/bin/sh +base_uri="$1" +domain="$(printf "%s\n" "$base_uri" | uricut -d)" +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)" + +### this is the verbose version for debugging. +### to enable debug mode, uncomment this, and comment out the next sed. +#sed \ +#'s|^<[ \t]*\([A-Za-z][A-Za-z+.-]*:[^ \t]*\)>|(absolute) \1|g;t +#s|^<[ \t]*\(#[^ \t]*\)>|(fragmentid_relative) '"${base_uri}"'\1|g;t +#s|^<[ \t]*\(?[^ \t]*\)>|(querystring_relative) '"$scheme"'://'"$domain""$path"'\1|g;t +#s|^<[ \t]*\(//[^ \t]*\)>|(scheme_relative) '"$scheme"':\1|g;t +#s|^<[ \t]*\(/[^ \t]*\)>|(absolute_path) '"$scheme"'://'"$domain"'\1|g;t +#s|^<[ \t]*\([^ \t]*\)>|(same-dir path relative) '"$scheme"'://'"$domain""$most_of_path"'/\1|g' + +sed -u \ +'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"':\1|g;t +s|^<[ \t]*\(/[^ \t]*\)>|'"$scheme"'://'"$domain"'\1|g;t +s|^<[ \t]*\([^ \t]*\)>|'"$scheme"'://'"$domain""$most_of_path"'/\1|g;t +s|^<[ \t]*\(.*\)>|<\1> UNHANDLED|g' |