changes to allow no trailing slash in database-instance URLs (updated not to assume dbname is always defined)