Skip to content

Commit

Permalink
feat: avoid duplicated separator URL (suggested by @dlbryant)
Browse files Browse the repository at this point in the history
some tools may cleanup duplicated bookmark by URL, such as Opera
  • Loading branch information
foray1010 committed May 19, 2019
1 parent a27d001 commit e7f605c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"classnames": "2.2.6",
"core-js": "3.0.1",
"lodash.debounce": "4.0.8",
"nanoid": "2.0.2",
"open-color": "1.6.3",
"ramda": "0.26.1",
"react": "16.8.6",
Expand Down Expand Up @@ -59,6 +60,7 @@
"@types/jest": "24.0.13",
"@types/lodash.debounce": "4.0.6",
"@types/mini-css-extract-plugin": "0.2.0",
"@types/nanoid": "2.0.0",
"@types/node": "12.0.2",
"@types/postcss-url": "8.0.1",
"@types/prompts": "2.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as CST from '../../../../constants'
import * as bookmarkCreators from '../../actions'
import {addSeparator} from './addSeparator'

jest.mock('nanoid', () => () => 'mocked-id')

const chance = Chance('addSeparator')

describe('addSeparator', () => {
Expand All @@ -26,7 +28,7 @@ describe('addSeparator', () => {
parentId,
index,
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -',
CST.SEPARATE_THIS_URL
CST.SEPARATE_THIS_URL + '#mocked-id'
)
)
)
Expand Down
4 changes: 3 additions & 1 deletion src/js/popup/reduxs/bookmark/saga/modules/addSeparator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import nanoId from 'nanoid'
import {SagaIterator} from 'redux-saga'
import {put} from 'redux-saga/effects'
import {ActionType} from 'typesafe-actions'
Expand All @@ -14,7 +15,8 @@ export function* addSeparator({
payload.parentId,
payload.index,
'- '.repeat(54).trim(),
CST.SEPARATE_THIS_URL
// avoid duplicated URL which may be cleaned up by third-party tools
CST.SEPARATE_THIS_URL + '#' + nanoId()
)
)
} catch (err) {
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,13 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/nanoid@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/nanoid/-/nanoid-2.0.0.tgz#b59002c475e6dfcc26e67ba563ff61b512e5ebf8"
integrity sha512-NtwPHfAyU3IDXdKAB2OMPpAauHBg9gUjpOYr3FAzI84D70nWdS8k5mryteLvT/s1ACeAFAkGg132/XJVN4qx/w==
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@12.0.2":
version "12.0.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40"
Expand Down Expand Up @@ -7459,6 +7466,11 @@ nan@^2.12.1, nan@^2.13.2:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7"
integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==

nanoid@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.0.2.tgz#2163edc84828cd42f9b8e4578979a4b5ffc1bb18"
integrity sha512-X4yQ8VHoFvHcykGunT2Jxrsm1c4vH5UKtau7LLJYXO1istCRE3jD8JxDyGCzN+h7dpWBCvWaSYgloRuphKRqUQ==

nanoid@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.0.1.tgz#deb55cac196e3f138071911dabbc3726eb048864"
Expand Down

0 comments on commit e7f605c

Please sign in to comment.