@@ -1707,6 +1707,25 @@ class DICOMwebClient {
17071707 ) ;
17081708 }
17091709
1710+ /**
1711+ * Generate an absolute URI from a relative URI.
1712+ * If the URI contains : then it is already absolute, return it.
1713+ * If the URI starts with /, then just add it after the wadoURL
1714+ * Otherwise, assume the URL is relative to the wadoURL, and add studies/STUDYUID to it.
1715+ * @param {string } studyUid to use in the full URL
1716+ * @param {string } uri to convert to full URL
1717+ * @returns a URL to the requested resource.
1718+ */
1719+ _handleRelativeURI ( studyUid , uri ) {
1720+ if ( ! uri || uri . indexOf ( ':' ) !== - 1 ) {
1721+ return uri ;
1722+ }
1723+ if ( uri [ 0 ] === '/' ) {
1724+ return this . wadoURL + uri ;
1725+ }
1726+ return `${ this . wadoURL } /studies/${ studyUid } /${ uri } ` ;
1727+ }
1728+
17101729 /**
17111730 * Retrieves and parses BulkData from a BulkDataURI location.
17121731 * Decodes the multipart encoded data and returns the resulting data
@@ -1715,15 +1734,17 @@ class DICOMwebClient {
17151734 * See http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.5.5.html
17161735 *
17171736 * @param {Object } options
1718- * @param {String } BulkDataURI - URI for retrieval of bulkdata
1737+ * @param {string } options. BulkDataURI to retrieve
17191738 * @returns {Promise<Array> } Bulkdata parts
17201739 */
17211740 retrieveBulkData ( options ) {
17221741 if ( ! ( 'BulkDataURI' in options ) ) {
17231742 throw new Error ( 'BulkDataURI is required.' ) ;
17241743 }
1744+ const { StudyInstanceUID, BulkDataURI } = options ;
17251745
1726- const url = options . BulkDataURI ;
1746+ // Allow relative URI's, assume it is relative to the studyUID directory
1747+ const url = this . _handleRelativeURI ( StudyInstanceUID , BulkDataURI ) ;
17271748 const { mediaTypes, byteRange } = options ;
17281749 const { withCredentials = false } = options ;
17291750 const { progressCallback = false } = options ;
0 commit comments