linkveil 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +28 -0
- data/.github/workflows/release.yml +72 -0
- data/LICENSE.txt +21 -0
- data/README.md +128 -0
- data/Rakefile +8 -0
- data/exe/linkveil +13 -0
- data/lib/linkveil/platform_detector.rb +27 -0
- data/lib/linkveil/query_cleaner.rb +23 -0
- data/lib/linkveil/sanitizer.rb +48 -0
- data/lib/linkveil/sanitizers/spotify.rb +10 -0
- data/lib/linkveil/sanitizers/tiktok.rb +10 -0
- data/lib/linkveil/sanitizers/youtube.rb +10 -0
- data/lib/linkveil/version.rb +5 -0
- data/lib/linkveil.rb +25 -0
- data/sig/linkveil.rbs +4 -0
- metadata +60 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2660cc23fbe2efa8b9b65511016571049fec3337856de39e4a57887c7ce04728
|
|
4
|
+
data.tar.gz: c1009d5aef352c18f2331f5ff68c5c860e07c6c669129d749d183f99ee956d3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4877a27de5b607cd7bf9191d9aa823aa43145861794ca592ec975da3569e69a6ddacb70a73c0bcab5136bcf14a7fefb7e081d19cc23bdad25156e26e00b352f3
|
|
7
|
+
data.tar.gz: db45583ec5a8e27159bffec17e259deb8fed9e41e1c785967b01fc6db063aec36ce78e83d1314e8b3ef5cf38d701f1591e25f8bea32cd5f351cbf2ee8399f956
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
name: Ruby ${{ matrix.ruby }}
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
ruby: ["3.2", "3.3", "3.4", "4.0"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Run RSpec
|
|
28
|
+
run: bundle exec rspec
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- "v*"
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
release:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: release
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v5
|
|
20
|
+
with:
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
|
|
23
|
+
- uses: ruby/setup-ruby@v1
|
|
24
|
+
with:
|
|
25
|
+
ruby-version: "4.0"
|
|
26
|
+
bundler-cache: true
|
|
27
|
+
|
|
28
|
+
- name: Authenticate with RubyGems
|
|
29
|
+
shell: bash
|
|
30
|
+
env:
|
|
31
|
+
RUBYGEMS_OWNER: "197318"
|
|
32
|
+
run: |
|
|
33
|
+
set -euo pipefail
|
|
34
|
+
|
|
35
|
+
: "${ACTIONS_ID_TOKEN_REQUEST_URL:?Missing OIDC URL}"
|
|
36
|
+
: "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:?Missing OIDC token}"
|
|
37
|
+
|
|
38
|
+
oidc_response=$(curl --fail-with-body -sS \
|
|
39
|
+
-H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
|
|
40
|
+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=rubygems.org")
|
|
41
|
+
|
|
42
|
+
jwt=$(jq -er '.value' <<< "$oidc_response")
|
|
43
|
+
|
|
44
|
+
payload=$(jq -n \
|
|
45
|
+
--arg jwt "$jwt" \
|
|
46
|
+
--arg owner "$RUBYGEMS_OWNER" \
|
|
47
|
+
'{jwt: $jwt, owner: $owner}')
|
|
48
|
+
|
|
49
|
+
http_code=$(curl -sS \
|
|
50
|
+
-o /tmp/rubygems-response.json \
|
|
51
|
+
-w '%{http_code}' \
|
|
52
|
+
-H 'Content-Type: application/json' \
|
|
53
|
+
-H 'Accept: application/json' \
|
|
54
|
+
--data-binary "$payload" \
|
|
55
|
+
https://rubygems.org/api/v1/oidc/trusted_publisher/exchange_token)
|
|
56
|
+
|
|
57
|
+
if [[ "$http_code" != "200" && "$http_code" != "201" ]]; then
|
|
58
|
+
echo "RubyGems OIDC exchange failed: HTTP $http_code"
|
|
59
|
+
exit 1
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
response=$(cat /tmp/rubygems-response.json)
|
|
63
|
+
|
|
64
|
+
key=$(jq -er '.rubygems_api_key' <<< "$response")
|
|
65
|
+
echo "::add-mask::$key"
|
|
66
|
+
echo "GEM_HOST_API_KEY=$key" >> "$GITHUB_ENV"
|
|
67
|
+
|
|
68
|
+
- name: Build gem
|
|
69
|
+
run: gem build linkveil.gemspec
|
|
70
|
+
|
|
71
|
+
- name: Publish gem
|
|
72
|
+
run: gem push linkveil-0.1.0.gem
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nelly Simkova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Linkveil
|
|
2
|
+
|
|
3
|
+
Linkveil is a lightweight Ruby gem that removes tracking parameters from shared URLs while preserving unrelated query parameters.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Remove platform-specific tracking parameters.
|
|
8
|
+
- Preserve unrelated query parameters and their original encoding.
|
|
9
|
+
- Support YouTube, Spotify, and TikTok.
|
|
10
|
+
- Keep unknown domains unchanged.
|
|
11
|
+
- Use Linkveil as a Ruby library or command-line tool.
|
|
12
|
+
- Extend supported platforms with a simple sanitizer DSL.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Add Linkveil to your Gemfile:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'linkveil'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then run:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
bundle install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or install it directly:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
gem install linkveil
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Ruby API
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
require 'linkveil'
|
|
40
|
+
|
|
41
|
+
Linkveil.clean('https://youtu.be/abc?si=secret&t=120')
|
|
42
|
+
# => "https://youtu.be/abc?t=120"
|
|
43
|
+
|
|
44
|
+
Linkveil.clean('https://open.spotify.com/track/abc123?si=secret')
|
|
45
|
+
# => "https://open.spotify.com/track/abc123"
|
|
46
|
+
|
|
47
|
+
Linkveil.clean('https://example.com/?foo=bar')
|
|
48
|
+
# => "https://example.com/?foo=bar"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Command-line interface
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
linkveil 'https://youtu.be/abc?si=secret&t=120'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Output:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
https://youtu.be/abc?t=120
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If no URL is provided, Linkveil prints usage instructions to stderr and exits with a non-zero status.
|
|
64
|
+
|
|
65
|
+
**Windows note:** Depending on your shell and the RubyGems-generated `.bat` launcher, URLs containing `&` may require special handling. When developing from source, you can run:
|
|
66
|
+
|
|
67
|
+
```powershell
|
|
68
|
+
ruby exe/linkveil 'https://youtu.be/abc?si=secret&t=120'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Supported platforms
|
|
72
|
+
|
|
73
|
+
| Platform | Domains | Removed parameters |
|
|
74
|
+
| -------- | --------------------------- | --------------------------------- |
|
|
75
|
+
| YouTube | `youtube.com`, `youtu.be` | `si`, `feature` |
|
|
76
|
+
| Spotify | `open.spotify.com` | `si` |
|
|
77
|
+
| TikTok | `tiktok.com` and subdomains | `is_from_webapp`, `sender_device` |
|
|
78
|
+
|
|
79
|
+
Linkveil only removes explicitly configured parameters. All other query parameters are preserved.
|
|
80
|
+
|
|
81
|
+
## Adding a sanitizer
|
|
82
|
+
|
|
83
|
+
Linkveil uses a small DSL to define platform-specific sanitizers.
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
module Linkveil
|
|
87
|
+
module Sanitizers
|
|
88
|
+
class Example < Linkveil::Sanitizer
|
|
89
|
+
domains 'example.com'
|
|
90
|
+
remove_params 'tracking_id', 'ref'
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Each sanitizer declares the domains it supports and the query parameters it removes.
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
Clone the repository:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
git clone https://github.com/sk8higher/linkveil.git
|
|
104
|
+
cd linkveil
|
|
105
|
+
bundle install
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Run the test suite:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
bundle exec rspec
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Build the gem locally:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
gem build linkveil.gemspec
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Contributing
|
|
121
|
+
|
|
122
|
+
Bug reports, suggestions, and pull requests are welcome.
|
|
123
|
+
|
|
124
|
+
When adding support for a new platform, please include tests demonstrating that tracking parameters are removed and unrelated parameters are preserved.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Linkveil is available under the [MIT License](LICENSE.txt).
|
data/Rakefile
ADDED
data/exe/linkveil
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Linkveil
|
|
4
|
+
module PlatformDetector
|
|
5
|
+
DOMAINS_LIST = {
|
|
6
|
+
youtube: ['youtube.com', 'youtu.be'],
|
|
7
|
+
tiktok: ['tiktok.com'],
|
|
8
|
+
spotify: ['spotify.com']
|
|
9
|
+
}.freeze
|
|
10
|
+
|
|
11
|
+
def self.detect(host)
|
|
12
|
+
return nil if host.nil?
|
|
13
|
+
|
|
14
|
+
host = host.downcase
|
|
15
|
+
|
|
16
|
+
DOMAINS_LIST.each do |platform, domains|
|
|
17
|
+
return platform if domains.any? { |domain| matches_domain?(host, domain) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.matches_domain?(host, domain)
|
|
24
|
+
host == domain || host.end_with?(".#{domain}")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Linkveil
|
|
4
|
+
module QueryCleaner
|
|
5
|
+
def self.clean(uri, remove:)
|
|
6
|
+
return uri.to_s if uri.query.nil?
|
|
7
|
+
|
|
8
|
+
fragments = uri.query.split('&', -1)
|
|
9
|
+
|
|
10
|
+
filtered = fragments.reject do |fragment|
|
|
11
|
+
key = fragment.partition('=').first
|
|
12
|
+
decoded_key = URI.decode_www_form_component(key)
|
|
13
|
+
|
|
14
|
+
remove.include?(decoded_key)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
new_query = filtered.join('&')
|
|
18
|
+
|
|
19
|
+
uri.query = new_query.empty? ? nil : new_query
|
|
20
|
+
uri.to_s
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Linkveil
|
|
4
|
+
class Sanitizer
|
|
5
|
+
@registry = []
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
attr_reader :registry
|
|
9
|
+
|
|
10
|
+
def inherited(subclass)
|
|
11
|
+
Linkveil::Sanitizer.registry << subclass
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def domains(*names)
|
|
16
|
+
if names.any?
|
|
17
|
+
@domains = names
|
|
18
|
+
else
|
|
19
|
+
@domains
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def remove_params(*names)
|
|
24
|
+
if names.any?
|
|
25
|
+
@remove_params = names
|
|
26
|
+
else
|
|
27
|
+
@remove_params
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def find_for(host)
|
|
32
|
+
return nil if host.nil?
|
|
33
|
+
|
|
34
|
+
host = host.downcase
|
|
35
|
+
|
|
36
|
+
@registry.find do |sanitizer|
|
|
37
|
+
Array(sanitizer.domains).any? do |domain|
|
|
38
|
+
PlatformDetector.matches_domain?(host, domain)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def clean(uri)
|
|
44
|
+
QueryCleaner.clean(uri, remove: remove_params)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/linkveil.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
require_relative 'linkveil/version'
|
|
5
|
+
require_relative 'linkveil/query_cleaner'
|
|
6
|
+
require_relative 'linkveil/platform_detector'
|
|
7
|
+
|
|
8
|
+
require_relative 'linkveil/sanitizer'
|
|
9
|
+
require_relative 'linkveil/sanitizers/youtube'
|
|
10
|
+
require_relative 'linkveil/sanitizers/spotify'
|
|
11
|
+
require_relative 'linkveil/sanitizers/tiktok'
|
|
12
|
+
|
|
13
|
+
module Linkveil
|
|
14
|
+
def self.clean(url)
|
|
15
|
+
uri = URI.parse(url)
|
|
16
|
+
|
|
17
|
+
sanitizer = Sanitizer.find_for(uri.host)
|
|
18
|
+
|
|
19
|
+
return url if sanitizer.nil?
|
|
20
|
+
|
|
21
|
+
sanitizer.clean(uri)
|
|
22
|
+
rescue URI::InvalidURIError
|
|
23
|
+
url
|
|
24
|
+
end
|
|
25
|
+
end
|
data/sig/linkveil.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: linkveil
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nelly Simkova
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Linkveil is a lightweight Ruby gem that removes tracking parameters from
|
|
13
|
+
URLs while preserving unrelated query parameters. It supports YouTube, Spotify,
|
|
14
|
+
and TikTok, and provides a simple command-line interface.
|
|
15
|
+
email:
|
|
16
|
+
- sk8high3r@ya.ru
|
|
17
|
+
executables:
|
|
18
|
+
- linkveil
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- ".github/workflows/ci.yml"
|
|
23
|
+
- ".github/workflows/release.yml"
|
|
24
|
+
- LICENSE.txt
|
|
25
|
+
- README.md
|
|
26
|
+
- Rakefile
|
|
27
|
+
- exe/linkveil
|
|
28
|
+
- lib/linkveil.rb
|
|
29
|
+
- lib/linkveil/platform_detector.rb
|
|
30
|
+
- lib/linkveil/query_cleaner.rb
|
|
31
|
+
- lib/linkveil/sanitizer.rb
|
|
32
|
+
- lib/linkveil/sanitizers/spotify.rb
|
|
33
|
+
- lib/linkveil/sanitizers/tiktok.rb
|
|
34
|
+
- lib/linkveil/sanitizers/youtube.rb
|
|
35
|
+
- lib/linkveil/version.rb
|
|
36
|
+
- sig/linkveil.rbs
|
|
37
|
+
homepage: https://github.com/sk8higher/linkveil
|
|
38
|
+
licenses:
|
|
39
|
+
- MIT
|
|
40
|
+
metadata:
|
|
41
|
+
homepage_uri: https://github.com/sk8higher/linkveil
|
|
42
|
+
source_code_uri: https://github.com/sk8higher/linkveil
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 3.2.0
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubygems_version: 4.0.20
|
|
58
|
+
specification_version: 4
|
|
59
|
+
summary: Remove tracking parameters from shared URLs
|
|
60
|
+
test_files: []
|