Q: What's the best way to return a clean URL by removing unwanted query params while keeping others? I need to have redirect rules for this page's routes that has unwanted query params. So this is what it looks like with the default unwanted query params.
https://some-test-url.com/b/laptops/1117?clubId=6612&offset=0&rootDimension=pcs_availability%253AOnlinepipsymbBrand%253ADell&searchCategoryId=1117&selectedFilter=all&sortKey=relevance&sortOrder=1
It should redirect to the cleaned URL. It should clean these from the URL under these conditions which are the default values. For the limit it should be removing both 48 and 20. I'm assuming that any other query params should be left that aren't listed below since they're not defaults.
searchCategoryId=all
selectedFilter=all
sortKey=relevance&sortOrder=1
limit=48 on desktop or limit=20 on mweb
clubId ever
offset=0

So the cleaned URL from above should look something like this
https://some-test-url.com/b/laptops/1117?rootDimension=pcs_availability%253AOnlinepipsymbBrand%253ADell
But for example if it's not a default query params for example
www.test.com/blah?offset=40&selectedFilter=online&clubId=3422
it should return
www.test.com/blah?offset=40&selectedFilter=online
What would be the best way to handle this? I tried doing it with regex but I wasn't able to get the expected result since it's a bit more complicated. Thanks for the help!

A: You can use URLSearchParams which is supported on all major browsers: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
Something like:
const params = new URLSearchParams(window.location.href);
for (var key of params.keys()){
    // do something with logic from your allow/block list
    // such as removing it:
    params.delete(key);
}

So, Beyonce’ Lip Synced The National Anthem? So? She Can’t Sing, Anyway.
She is just an example of how our light has gone out. Why all the hype? This snot-nosed, black, liberal brat entertained Gaddafi and then when Obama helped murder Gaddafi, (her friend) she said nothing.
  I am glad she lip-synced. She is a fake. All leftists are FAKE. ALL Obama-bots are FAKERs. No talent, mediocres at best– in everything they do.
Why would anyone want a leftist-NAZI, Obama-worshiping creep singing our national anthem?? One that was written by a great patriot, Frances Scott Key.
Week 2 of the 2009 NFL regular season is in the books, and your Buffalo Bills are 1-1 - though they should be 2-0. Before we move on to take a look at the Bills' next big game - and yes, it is very much a big game - we'll take one last look back today on the Bills' 33-20 triumph over the Tampa Bay Buccaneers in Week 2.
We did this last week after the Bills' opening week loss, and we'll do it every week - so mark your calendars, folks, because Tuesdays are film sessions at Buffalo Rumblings.
Trent Edwards deserves a bit more praise. Buffalo put up 20 points and took a 20-14 lead into the half, but Trent Edwards didn't have a particularly great first half. True, his interception came in the second half - and for the record, that was just a ball that got away from Trent, and that's a difficult throw to make when you're on the money - but Edwards completed 15 of his 18 throws in the second half. Those plays went for 145 yards, and most importantly, they came in the face of very solid Tampa pressure - Brad Butler was out of the game at that point, and the Bucs were blitzing a bit more frequently as they played catch-up. "Poise" is one of the most over-used cliches in football, but our quarterback has it.
On our new starting right tackle... Jonathan Scott got into the game very late in the second quarter and, obviously, the rest of the first half. Folks, Brad Butler he is not - and though his performance was solid enough given the circumstances, the Bills' offensive line now has a clear weak link.
Scott is average in pretty much every way - he'll very rarely hurt you (which he did on Sunday, allowing a Jimmy Wilkerson sack on Edwards), but he's not a tremendous help, either. He can move around and he's pretty technically sound, but he doesn't flash dominance, as every other lineman has (and did on Sunday, by the way). Dick Jauron said yesterday after confirming Butler's season-ending knee injury that the Bills would explore free agent options at right tackle. It's pretty clear why - Scott proved he's dependable as a depth player, but he's most definitely a liability as a starter. Teams will find ways to exploit him, and we have yet to reach the part of the schedule where the right tackle will be responsible for blocking left defensive ends (lining up across from the RT) such as Mario Williams and Julius Peppers.
On Tampa's coverages and our receivers. Bucs defensive coordinator Jim Bates employs a weird defensive scheme - his two deep safeties are closer to the line of scrimmage than most other coordinators would have them. Their corners jam on nearly every play - it's a rather aggressive scheme speaking strictly on the secondary. Terrell Owens and Lee Evans struggled to get open on what you might call "normal" routes - i.e. curls, slants, posts, etc. Alex Van Pelt played it the smartest way - he ran Fred Jackson rampant until the Bucs had no choice to commit an extra man in the box, and then he hit them vertically. Edwards had three perfectly thrown bombs on the day - and all three of them should have been caught. As it is, two of them were, and they both went for scores. New Orleans, next week's opponent, plays a slightly different philosophy in their secondary, but they, too, can be exploited defensively.
More love for Donte Whitner. I said it yesterday, but it bears repeating - Donte Whitner is off to a roaring start this season. He's picked up 18 tackles, a pick-six, and a fourth-down stop in two games. He's all over the field, and playing faster than I've ever seen him play. If he keeps this up - and we'd certainly like to see more - he could be on his way to a Pro Bowl-type season. He's looked that good.
Blitz, blitz and blitz some more. By my count - and Allen Wilson of The Buffalo News actually confirmed this - Buffalo blitzed 32 times on Sunday. The majority were "dogs" (five rushers), but at least a dozen were flat-out blitzes (six or more rushers). Buffalo only got Leftwich to the ground twice, but on most of his pass attempts, Leftwich was either shrugging off defenders or getting hit as he released. The pressure was good, though it could stand to be a little less hit-and-miss. Getting pressure was critical to the defense's success on Sunday, and it will be even more critically important with Drew Brees coming into town this weekend.
DT Kyle Williams, however, was the star - my gosh, this kid can play. I'd like to see him used a bit more on third down situations, because no tackle on this roster is better at shooting gaps. Williams needs to become a bit more adept at shedding blockers; if he could do that, he'd be a dominant force against both the run and the pass. But Williams' play highlights Buffalo's need to continue to pressure up the middle. Too often on Sunday, Leftwich had pressure on him from the edges, but was able to calmly able to step up into the pocket and deliver the ball down the field. Buffalo's pressure was good, but the more varied in location they can generate it from, the better.
We need to get healthy in the secondary. Reggie Corner deserves a little love, because he was asked to play a role he should never have to play - outside corner. The man is a slot corner, and a pretty good one, but he should not be asked to cover tall, bulky receivers on go patterns on the sidelines - that's a recipe for disaster, as Tampa's converted fourth-and-10 indicates. The Bills very clearly missed having Leodis McKelvin's athleticism back there when he left; Ashton Youboty just isn't in the same mold. There has been no update on McKelvin's injured ankle to this point, but the team may get Drayton Florence back this week - so that's a start. But again - Drew Brees is coming to town. We need all the healthy, active defensive backs we can put on the field.
Special Teams need some work. Everything about special teams - with the exception of the kicks and punts themselves - is sloppy right now. Garrison Sanborn is a really, really accurate long snapper. Rian Lindell had great depth on his kickoffs this week. Brian Moorman