#! /bin/bash

path=$1

coll=$(dirname "$path")
data=$(basename "$path")

# Test if path is relative
if [ $(realpath -m "$coll") != "$coll"  ] ; then
    # use ipwd to get absolute collection name
    coll=$(realpath -m "$(ipwd)/$coll")
fi

# build URL
iquest "https://%s%s/%s" "SELECT RESC_LOC, COLL_NAME, DATA_NAME WHERE DATA_NAME = '$data' AND COLL_NAME = '$coll'"
