Port of https://github.com/irods/irods-legacy/tree/master/iRODS/modules/URL