mozilla.org/devtools-user/"; /** * Get the MDN URL for the specified header. * * @param {string} header Name of the header for the baseURL to use. * * @return {string} The MDN URL for the header, or null if not available. */ function getHeadersURL(header) { const lowerCaseHeader = header.toLowerCase(); const idx = SUPPORTED_HEADERS.findIndex( item => item.toLowerCase() === lowerCaseHeader ); return idx > -1 ? `${MDN_URL}Web/HTTP/Reference/Headers/${SUPPORTED_HEADERS[idx] + getGAParams()}` : null; } /** * Get the MDN URL for the specified HTTP status code. * * @param {string} HTTP status code for the baseURL to use. * * @return {string} The MDN URL for the HTTP status code, or null if not available. */ function getHTTPStatusCodeURL(statusCode, panelId) { return ( (SUPPORTED_HTTP_CODES.includes(statusCode) ? `${MDN_URL}Web/HTTP/Reference/Status/${statusCode}` : MDN_STATUS_CODES_LIST_URL) + getGAParams(panelId) ); } /** * Get the URL of the Timings tag for Network Monitor. * * @return {string} the URL of the Timings tag for Network Monitor. */ function getNetMonitorTimingsURL() { return `${USER_DOC_URL}network_monitor/request_details/#network-monitor-request-details-timings-tab`; } /** * Get the URL for Performance Analysis * * @return {string} The URL for the documentation of Performance Analysis. */ function getPerformanceAnalysisURL() { return `${USER_DOC_URL}network_monitor/performance_analysis/`; } /** * Get the URL for Filter box * * @return {string} The URL for the documentation of Filter box. */ function getFilterBoxURL() { return `${USER_DOC_URL}network_monitor/request_list/#filtering-by-properties`; } /** * Get the MDN URL for Tracking Protection * * @return {string} The MDN URL for the documentation of Tracking Protection. */ function getTrackingProtectionURL() { return `${MDN_URL}Web/Privacy/Guides/Firefox_tracking_protection${getGAParams()}`; } /** * Get the MDN URL for CORS error reason, falls back to generic cors error page * if reason is not understood. * * @param {int} reason: Blocked Reason message from `netmonitor/src/constants.js` * * @returns {string} the MDN URL for the documentation of CORS errors */ function getCORSErrorURL(reason) { // Map from blocked reasons from netmonitor/src/constants.js to the correct // URL fragment to append to MDN_URL const reasonMap = new Map([ [1001, "CORSDisabled"], [1002, "CORSDidNotSucceed"], [1003, "CORSRequestNotHttp"], [1004, "CORSMultipleAllowOriginNotAllowed"], [1005, "CORSMissingAllowOrigin"], [1006, "CORSNotSupportingCredentials"], [1007, "CORSAllowOriginNotMatchingOrigin"], [1008, "CORSMIssingAllowCredentials"], [1009, "CORSOriginHeaderNotAdded"], [1010, "CORSExternalRedirectNotAllowed"], [1011, "CORSPreflightDidNotSucceed"], [1012, "CORSInvalidAllowMethod"], [1013, "CORSMethodNotFound"], [1014, "CORSInvalidAllowHeader"], [1015, "CORSMissingAllowHeaderFromPreflight"], ]); const urlFrag = reasonMap.get(reason) || ""; return `${MDN_URL}Web/HTTP/Guides/CORS/Errors/${urlFrag}`; } module.exports = { getHeadersURL, getHTTPStatusCodeURL, getNetMonitorTimingsURL, getPerformanceAnalysisURL, getFilterBoxURL, getTrackingProtectionURL, getCORSErrorURL, }; PK