From 01e80abe9215e6a403fbaae190a85a84d8c849ae Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 19 Jul 2017 09:12:41 +0200 Subject: [PATCH] Bug 1379113 - Deleting non-existing URL query parameters should remove ?, r=qdot --- dom/url/URLSearchParams.cpp | 11 +++-------- dom/url/URLSearchParams.h | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dom/url/URLSearchParams.cpp b/dom/url/URLSearchParams.cpp index 0a8ad9cf1515..a63a35f2da4b 100644 --- a/dom/url/URLSearchParams.cpp +++ b/dom/url/URLSearchParams.cpp @@ -86,20 +86,16 @@ URLParams::Set(const nsAString& aName, const nsAString& aValue) param->mValue = aValue; } -bool +void URLParams::Delete(const nsAString& aName) { - bool found = false; for (uint32_t i = 0; i < mParams.Length();) { if (mParams[i].mKey.Equals(aName)) { mParams.RemoveElementAt(i); - found = true; } else { ++i; } } - - return found; } void @@ -375,9 +371,8 @@ URLSearchParams::Has(const nsAString& aName) void URLSearchParams::Delete(const nsAString& aName) { - if (mParams->Delete(aName)) { - NotifyObserver(); - } + mParams->Delete(aName); + NotifyObserver(); } void diff --git a/dom/url/URLSearchParams.h b/dom/url/URLSearchParams.h index c2d050ec55f6..a108a3c53055 100644 --- a/dom/url/URLSearchParams.h +++ b/dom/url/URLSearchParams.h @@ -77,8 +77,7 @@ public: bool Has(const nsAString& aName); - // Returns true if aName was found and deleted, false otherwise. - bool Delete(const nsAString& aName); + void Delete(const nsAString& aName); void DeleteAll() {