Skip to content

Commit

Permalink
Fix hash handling for highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustem Mussabekov committed Dec 24, 2024
1 parent c3d876b commit ba23c6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "5.6.65",
"version": "5.6.66",
"description": "All-in-one bookmark manager",
"author": "Rustem Mussabekov",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/format/url/normalizeURL.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _normalizeURL from 'normalize-url'

export function normalizeURL(str) {
export function normalizeURL(str, options) {
try{
return _normalizeURL(str)
return _normalizeURL(str, options)
} catch(e) {
return str
}
Expand Down
19 changes: 16 additions & 3 deletions src/target/extension/background/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@ const options = {
var items = new Map()
var loading = false

function simplifyURL(url) {
return normalizeURL(url, {
stripHash: !new URL(url).hash.includes('/'), //do not strip hash when it seems an SPA
stripWWW: true,
removeQueryParameters: [
//tracking
/^utm_\w+/i, 'ref', 'ref_src', 'source',
//youtube specific
...(/youtube|youtu\.be/i.test(url) ? ['t'] : []),
]
})
}

//has
export function has(url) {
return items.has(normalizeURL(url))
return items.has(simplifyURL(url))
}

export function add(url, id) {
Expand All @@ -23,7 +36,7 @@ export function add(url, id) {

//getId
export function getId(url) {
return items.get(normalizeURL(url))
return items.get(simplifyURL(url))
}

//reload
Expand Down Expand Up @@ -60,7 +73,7 @@ export async function reload(force=false) {

text.split('\n').forEach(line=>{
const [_id, href] = line.split(options.divider)
const url = normalizeURL(
const url = simplifyURL(
decodeURIComponent(
href||''
)
Expand Down

0 comments on commit ba23c6b

Please sign in to comment.