Skip to content

Commit

Permalink
Simplify the Getting Started about how to remove parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibanami committed Jul 8, 2024
1 parent 3deb645 commit ef77a27
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 101 deletions.
72 changes: 0 additions & 72 deletions docs/assets/remove-parameters-without-junks.redirectweb

This file was deleted.

31 changes: 19 additions & 12 deletions docs/assets/remove-parameters.redirectweb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,32 @@
"kind": "RedirectList",
"redirects": [
{
"captureGroupProcesses": [],
"captureGroupProcesses": [
{
"groupIndex": 0,
"process": {
"id": "replaceOccurrences",
"matchingPattern": {
"type": "regularExpression",
"value": "&?source=[^&]*"
},
"replacement": ""
}
}
],
"comments": "",
"destinationURLPattern": "$1$2$4",
"destinationURLPattern": "$0",
"exampleURLs": [
"https:\/\/example.com\/hello?theme=dark",
"https:\/\/example.com\/hello",
"https:\/\/example.com\/hello?source=twitter",
"https:\/\/example.com\/hello?theme=dark&source=twitter",
"https:\/\/example.com\/hello?source=twitter&theme=dark",
"https:\/\/example.com\/hello?theme=dark&source=twitter&nosource=no",
"https:\/\/example.com\/hello?theme=dark&source=twitter&nosource=no"
"https:\/\/example.com\/?source=twitter",
"https:\/\/example.com\/?hello=world&source=twitter&foo=bar"
],
"excludeURLPatterns": [],
"kind": "Redirect",
"sourceURLPattern": {
"type": "regularExpression",
"value": "(https:\/\/example.com\/[^?]*)(.*[&?])(source=[^&]*)(.*)"
"type": "wildcard",
"value": "https:\/\/example.com\/*"
},
"title": "Remove source parameter"
"title": "Remove parameters"
}
]
}
46 changes: 29 additions & 17 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,36 @@ Now, Redirect Web brings you to the meditation when you access Twitter!

**[⬇️ Download the Rule](assets/reduce-twitter-addiction.redirectweb ':ignore')**

## Case 2: Remove Query Parameters from URL

## Case 2: Add Query Parameters to URL
Suppose there is a query parameter `source=twitter` in a URL of `example.com`, and you decided to remove it to anonymize yourself.

In this case, the *Capturing Group Processing* option is the easiest way.:

* **Redirect From**: `https://example.com/*` (Wildcard)
* **Redirect To**: `$0`
* **Capturing Group Processing**:
* **Group**: `$0`
* **Process**: Replace Occurrences
* **Target**: `&?source=[^&]*`
* **Replacement**: `` (none)
* **Text Pattern**: Regular Expression

**[⬇️ Download the Rule](assets/remove-parameters.redirectweb ':ignore')**

This rule works as follows:

```
https://example.com/?source=twitter
↪ https://example.com/?
https://example.com/?hello=world&source=twitter&foo=bar
↪ https://example.com/?hello=world&foo=bar
```

If you want to remove more parameters, add more processes.

## Case 3: Add Query Parameters to URL

Let's say there is a website called `example.com` that shows a mobile layout by default, but you prefer their desktop layout. Fortunately, the website supports a `layout` query parameter to specify which layout the website displays. Let's create a rule that adds `layout=desktop` automatically.

Expand Down Expand Up @@ -123,19 +151,3 @@ In conclusion, this is the final output:
**[⬇️ Download the Rule](assets/add-parameters.redirectweb ':ignore')**

This is merely an example. You can also create multiple rules to handle each problem. It can be much simpler.


## Case 3: Remove Query Parameters from URL

Suppose you find out a query parameter `source=twitter` that a website `example.com` uses to track you, and you decide to remove it to anonymize yourself.

The rule would look like this:

* **Redirect From**: `(https://example.com/[^?]*)(.*[&?])(source=[^&]*)(.*)` (Regular Expression)
* **Redirect To**: `$1$2$4`

**[⬇️ Download the Rule](assets/remove-parameters.redirectweb ':ignore')**

The destination may include unnecessary characters such as `?` at the end, `&&`, and `?&`. Although they don't cause any problems in general, check the rule you can download from the following link if you wish to remove them:

**[⬇️ Download the Rule](assets/remove-parameters-without-junks.redirectweb ':ignore')**

0 comments on commit ef77a27

Please sign in to comment.