From 13a04a9ac4a831f190496e5cc806ca1f33564cbb Mon Sep 17 00:00:00 2001 From: William Melody Date: Sun, 21 Jan 2024 17:01:28 -0800 Subject: [PATCH] Use Chrome for bookmarks by default when available. --- nb | 5 ++++- test/bookmark.bats | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nb b/nb index 67bc8f3db..3aa2ce5a3 100755 --- a/nb +++ b/nb @@ -9989,7 +9989,10 @@ _download_from() { local _target_path="${2:-}" - if ((${NB_BROWSER_DOWNLOAD_ENABLED:-})) + if ((${NB_BROWSER_DOWNLOAD_ENABLED:-1})) && { + [[ "${_url}" =~ .html$ ]] || + [[ ! "${_url}" =~ .[a-zA-Z0-9]$ ]] + } then if _command_exists "google-chrome" then diff --git a/test/bookmark.bats b/test/bookmark.bats index 22414ff13..426942dd8 100644 --- a/test/bookmark.bats +++ b/test/bookmark.bats @@ -1249,6 +1249,9 @@ $(cat "${NB_TEST_BASE_PATH}/fixtures/example.com.md")" @test "'bookmark --save-source' creates new note with HTML content." { { "${_NB}" init + + # Skip browser download to avoid extra whitespace added to output by Chrome. + export NB_BROWSER_DOWNLOAD_ENABLED=0 } run "${_NB}" bookmark "${_BOOKMARK_URL}" --save-source