Skip to content

fix: replace deprecated substr() with substring() in URLOptionsManager#810

Open
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517:fix/url-options-manager-replace-deprecated-substr
Open

fix: replace deprecated substr() with substring() in URLOptionsManager#810
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517:fix/url-options-manager-replace-deprecated-substr

Conversation

@GaneshPatil7517
Copy link

@GaneshPatil7517 GaneshPatil7517 commented Feb 26, 2026

hello @EdwardMoyse
What
Replaced the deprecated String.prototype.substr() call in url-options-manager.ts with String.prototype.substring(), along with a guard for URLs that don't contain a query string.

Why
substr() is deprecated in ECMAScript and behaves incorrectly when the URL has no ? character — lastIndexOf('?') returns -1, and substr(-1) extracts just the last character of the URL instead of returning an empty string. This leads to unexpected URLSearchParams being parsed.

How
Used indexOf('?') to find the query string position
Added a guard: if no ? is found, pass an empty string to URLSearchParams
Used substring() instead of substr() when the ? is present

Fixes #807

…ger\n\nReplace window.location.href.substr() with substring() and add a guard\nfor missing query string to prevent incorrect behavior when the URL\nhas no '?' character."
@GaneshPatil7517 GaneshPatil7517 force-pushed the fix/url-options-manager-replace-deprecated-substr branch from cffba64 to ddbd110 Compare February 26, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: url-options-manager uses deprecated substr() causing edge-case failures

1 participant