@@ -1715,6 +1715,25 @@ class DICOMwebClient {
17151715 ) ;
17161716 }
17171717
1718+ /**
1719+ * Generate an absolute URI from a relative URI.
1720+ * If the URI contains : then it is already absolute, return it.
1721+ * If the URI starts with /, then just add it after the wadoURL
1722+ * Otherwise, assume the URL is relative to the wadoURL, and add studies/STUDYUID to it.
1723+ * @param {string } studyUid to use in the full URL
1724+ * @param {string } uri to convert to full URL
1725+ * @returns a URL to the requested resource.
1726+ */
1727+ _handleRelativeURI ( studyUid , uri ) {
1728+ if ( ! uri || uri . indexOf ( ':' ) !== - 1 ) {
1729+ return uri ;
1730+ }
1731+ if ( uri [ 0 ] === '/' ) {
1732+ return this . wadoURL + uri ;
1733+ }
1734+ return `${ this . wadoURL } /studies/${ studyUid } /${ uri } ` ;
1735+ }
1736+
17181737 /**
17191738 * Retrieves and parses BulkData from a BulkDataURI location.
17201739 * Decodes the multipart encoded data and returns the resulting data
@@ -1732,8 +1751,10 @@ class DICOMwebClient {
17321751 if ( ! ( 'BulkDataURI' in options ) ) {
17331752 throw new Error ( 'BulkDataURI is required.' ) ;
17341753 }
1754+ const { StudyInstanceUID, BulkDataURI } = options ;
17351755
1736- const url = options . BulkDataURI ;
1756+ // Allow relative URI's, assume it is relative to the studyUID directory
1757+ const url = this . _handleRelativeURI ( StudyInstanceUID , BulkDataURI ) ;
17371758 const { mediaTypes, byteRange } = options ;
17381759 const { withCredentials = false } = options ;
17391760 const { progressCallback = false } = options ;
0 commit comments