diff --git a/packages/runtimes/js/src/helpers/bundle-url-common.js b/packages/runtimes/js/src/helpers/bundle-url-common.js index 089675b22..8a44855a8 100644 --- a/packages/runtimes/js/src/helpers/bundle-url-common.js +++ b/packages/runtimes/js/src/helpers/bundle-url-common.js @@ -1,4 +1,8 @@ -// Get the URL without the filename (last / segment) +/** Get the URL without the filename (last / segment) + * + * @param {string} url + * @returns {string} The URL with the file name removed + */ function getBaseURL(url) { return url.slice(0, url.lastIndexOf('/')) + '/'; } diff --git a/packages/runtimes/js/src/helpers/bundle-url-shards.js b/packages/runtimes/js/src/helpers/bundle-url-shards.js index d1d695ef0..dfdde69ea 100644 --- a/packages/runtimes/js/src/helpers/bundle-url-shards.js +++ b/packages/runtimes/js/src/helpers/bundle-url-shards.js @@ -2,6 +2,15 @@ const {getBaseURL, stackTraceUrlRegexp} = require('./bundle-url-common'); const bundleURL = {}; +/** + * Retrieves the sharded bundle URL based on the bundle name and the maximum number of shards. + * + * @param {string} bundleName - The file name of the requested bundle. + * @param {number} maxShards - The maximum number of domain shards available. + * @param {Error} inputError - An error object to extract the stack trace from + * (for testing purposes). + * @returns {string} The URL of the sharded bundle, without file name. + */ function getShardedBundleURL(bundleName, maxShards, inputError) { let value = bundleURL[bundleName]; diff --git a/packages/runtimes/js/src/helpers/bundle-url.js b/packages/runtimes/js/src/helpers/bundle-url.js index 341ee41a0..bbd4161b3 100644 --- a/packages/runtimes/js/src/helpers/bundle-url.js +++ b/packages/runtimes/js/src/helpers/bundle-url.js @@ -2,6 +2,13 @@ const {getBaseURL, stackTraceUrlRegexp} = require('./bundle-url-common'); const bundleURL = {}; +/** + * Retrieves the cached bundle URL for a given identifier. + * If the URL is not cached, it computes and stores it in the cache. + * + * @param {string} id - The identifier for the bundle. + * @returns {string} The URL of the bundle, without file name. + */ function getBundleURLCached(id) { let value = bundleURL[id]; @@ -28,6 +35,10 @@ function getBundleURL() { return '/'; } +/** + * @param {string} url + * @returns {string} + */ function getOrigin(url) { return new URL(url).origin; }