diff --git a/Build/Sources/TypeScript/backend/utility.ts b/Build/Sources/TypeScript/backend/utility.ts index bf2cb99f2d27b369a6f33e94cd64ddedee5fd574..1b980590209e1f0e1e8b3e32748b1804589c1673 100644 --- a/Build/Sources/TypeScript/backend/utility.ts +++ b/Build/Sources/TypeScript/backend/utility.ts @@ -75,8 +75,11 @@ class Utility { * @param {string} key * @param {string} value * @returns {string} + * @deprecated will be removed in TYPO3 v14 */ public static updateQueryStringParameter(url: string, key: string, value: string): string { + console.warn('Utility.updateQueryStringParameter() has been marked as deprecated and will be removed in TYPO3 v14.'); + const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i'); const separator = url.includes('?') ? '&' : '?'; diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/utility.js b/typo3/sysext/backend/Resources/Public/JavaScript/utility.js index 8f9c53d9658830bd0802f26cec9e184c2f0aac94..c89806bc7a0391d166cdbbd98572b95687f0a60f 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/utility.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/utility.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -class Utility{static trimExplode(t,e){return e.split(t).map((t=>t.trim())).filter((t=>""!==t))}static trimItems(t){return t.map((t=>t instanceof String?t.trim():t))}static intExplode(t,e,r=!1){return e.split(t).map((t=>parseInt(t,10))).filter((t=>!isNaN(t)||r&&0===t))}static isNumber(t){return!isNaN(parseFloat(t.toString()))&&isFinite(t)}static updateQueryStringParameter(t,e,r){const i=new RegExp("([?&])"+e+"=.*?(&|$)","i"),a=t.includes("?")?"&":"?";return t.match(i)?t.replace(i,"$1"+e+"="+r+"$2"):t+a+e+"="+r}static convertFormToObject(t){const e={};return t.querySelectorAll("input, select, textarea").forEach((t=>{const r=t.name,i=t.value;if(r)if("input"===t.tagName.toLowerCase()&&"checkbox"==t.type){const a=t;void 0===e[r]&&(e[r]=[]),a.checked&&e[r].push(i)}else e[r]=i})),e}static mergeDeep(...t){const e=t=>t&&"object"==typeof t;return t.reduce(((t,r)=>(Object.keys(r).forEach((i=>{const a=t[i],n=r[i];Array.isArray(a)&&Array.isArray(n)?t[i]=a.concat(...n):e(a)&&e(n)?t[i]=Utility.mergeDeep(a,n):t[i]=n})),t)),{})}static urlsPointToSameServerSideResource(t,e){if(!t||!e)return!1;const r=window.location.origin;try{const i=new URL(t,Utility.isValidUrl(t)?void 0:r),a=new URL(e,Utility.isValidUrl(e)?void 0:r),n=i.origin+i.pathname+i.search;return n===a.origin+a.pathname+a.search}catch(t){return!1}}static isValidUrl(t){try{return new URL(t),!0}catch(t){return!1}}}export default Utility; \ No newline at end of file +class Utility{static trimExplode(t,e){return e.split(t).map((t=>t.trim())).filter((t=>""!==t))}static trimItems(t){return t.map((t=>t instanceof String?t.trim():t))}static intExplode(t,e,r=!1){return e.split(t).map((t=>parseInt(t,10))).filter((t=>!isNaN(t)||r&&0===t))}static isNumber(t){return!isNaN(parseFloat(t.toString()))&&isFinite(t)}static updateQueryStringParameter(t,e,r){console.warn("Utility.updateQueryStringParameter() has been marked as deprecated and will be removed in TYPO3 v14.");const i=new RegExp("([?&])"+e+"=.*?(&|$)","i"),a=t.includes("?")?"&":"?";return t.match(i)?t.replace(i,"$1"+e+"="+r+"$2"):t+a+e+"="+r}static convertFormToObject(t){const e={};return t.querySelectorAll("input, select, textarea").forEach((t=>{const r=t.name,i=t.value;if(r)if("input"===t.tagName.toLowerCase()&&"checkbox"==t.type){const a=t;void 0===e[r]&&(e[r]=[]),a.checked&&e[r].push(i)}else e[r]=i})),e}static mergeDeep(...t){const e=t=>t&&"object"==typeof t;return t.reduce(((t,r)=>(Object.keys(r).forEach((i=>{const a=t[i],n=r[i];Array.isArray(a)&&Array.isArray(n)?t[i]=a.concat(...n):e(a)&&e(n)?t[i]=Utility.mergeDeep(a,n):t[i]=n})),t)),{})}static urlsPointToSameServerSideResource(t,e){if(!t||!e)return!1;const r=window.location.origin;try{const i=new URL(t,Utility.isValidUrl(t)?void 0:r),a=new URL(e,Utility.isValidUrl(e)?void 0:r),n=i.origin+i.pathname+i.search;return n===a.origin+a.pathname+a.search}catch(t){return!1}}static isValidUrl(t){try{return new URL(t),!0}catch(t){return!1}}}export default Utility; \ No newline at end of file diff --git a/typo3/sysext/core/Documentation/Changelog/13.2/Deprecation-104154-DeprecateUtilityupdateQueryStringParameter.rst b/typo3/sysext/core/Documentation/Changelog/13.2/Deprecation-104154-DeprecateUtilityupdateQueryStringParameter.rst new file mode 100644 index 0000000000000000000000000000000000000000..adc137ee1ca809244ea11c83763b23a728a5b63c --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/13.2/Deprecation-104154-DeprecateUtilityupdateQueryStringParameter.rst @@ -0,0 +1,48 @@ +.. include:: /Includes.rst.txt + +.. _deprecation-104154-1718802119: + +===================================================================== +Deprecation: #104154 - Deprecate Utility.updateQueryStringParameter() +===================================================================== + +See :issue:`104154` + +Description +=========== + +The method :js:`Utility.updateQueryStringParameter()` from the module +:js:`@typo3/backend/utility.js` was introduced in TYPO3 v8 as a bugfix for +highlighting in the old ExtJS-based page tree. With removal of ExtJS in TYPO3 v9, +the method became unused since then. + +Since a safe removal of the method cannot be guaranteed as this point, it is +therefore deprecated. + + +Impact +====== + +Calling :js:`Utility.updateQueryStringParameter()` will result in a JavaScript +warning. + + +Affected installations +====================== + +All 3rd party extensions using the deprecated method are affected. + + +Migration +========= + +Nowadays, JavaScript supports the :js:`URL` and its related :js:`URLSearchParams` +object that can be used to achieve the same result: + +.. code-block:: javascript + + const url = new URL('http://localhost?baz=baz'); + url.searchParams.set('baz', 'bencer'); + const urlString = url.toString(); // http://localhost?baz=bencer + +.. index:: JavaScript, NotScanned, ext:backend