From 3e8271816965e73354b840266fcb55dffb863c24 Mon Sep 17 00:00:00 2001 From: Konnor Rogers Date: Fri, 16 Aug 2024 16:53:23 -0400 Subject: [PATCH] Konnorrogers/fix remote links (#218) * fix remote links * fix remote links * fix inde.html.erb * fix workflow * eslint -.- * update bundler --- .github/workflows/tests.yml | 2 +- .tool-versions | 2 +- Gemfile | 5 +- Gemfile.lock | 223 +++++++++++++++++------------- src/methodSubmission.ts | 3 +- src/utils/misc.ts | 10 +- test/rails/dummy/config/vite.json | 4 +- 7 files changed, 143 insertions(+), 106 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b95c933..3dea642 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,7 +53,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v2 + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true diff --git a/.tool-versions b/.tool-versions index a4023dc..520a168 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -ruby 2.7.5 +ruby 3.1.3 diff --git a/Gemfile b/Gemfile index e8aeb5b..3cdbfe6 100644 --- a/Gemfile +++ b/Gemfile @@ -2,11 +2,11 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' -gem 'rails', '~> 6.1.3', '>= 6.1.3.2' +gem 'rails', '~> 7.0' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use Puma as the app server -gem 'puma', '~> 5.0' +gem 'puma', '~> 6.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Active Model has_secure_password @@ -33,7 +33,6 @@ group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 3.26' gem "evil_systems", "~> 0.2" - gem 'webdrivers', '~> 5.0', require: false gem "selenium-webdriver", "~> 4.1" end diff --git a/Gemfile.lock b/Gemfile.lock index 7c60eaa..c3aa241 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,100 +1,122 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.8) - actionpack (= 6.1.7.8) - activesupport (= 6.1.7.8) + actioncable (7.2.0) + actionpack (= 7.2.0) + activesupport (= 7.2.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.8) - actionpack (= 6.1.7.8) - activejob (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) - mail (>= 2.7.1) - actionmailer (6.1.7.8) - actionpack (= 6.1.7.8) - actionview (= 6.1.7.8) - activejob (= 6.1.7.8) - activesupport (= 6.1.7.8) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.1.7.8) - actionview (= 6.1.7.8) - activesupport (= 6.1.7.8) - rack (~> 2.0, >= 2.0.9) + zeitwerk (~> 2.6) + actionmailbox (7.2.0) + actionpack (= 7.2.0) + activejob (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) + mail (>= 2.8.0) + actionmailer (7.2.0) + actionpack (= 7.2.0) + actionview (= 7.2.0) + activejob (= 7.2.0) + activesupport (= 7.2.0) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.0) + actionview (= 7.2.0) + activesupport (= 7.2.0) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4, < 3.2) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.8) - actionpack (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.0) + actionpack (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.8) - activesupport (= 6.1.7.8) + actionview (7.2.0) + activesupport (= 7.2.0) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.8) - activesupport (= 6.1.7.8) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.2.0) + activesupport (= 7.2.0) globalid (>= 0.3.6) - activemodel (6.1.7.8) - activesupport (= 6.1.7.8) - activerecord (6.1.7.8) - activemodel (= 6.1.7.8) - activesupport (= 6.1.7.8) - activestorage (6.1.7.8) - actionpack (= 6.1.7.8) - activejob (= 6.1.7.8) - activerecord (= 6.1.7.8) - activesupport (= 6.1.7.8) + activemodel (7.2.0) + activesupport (= 7.2.0) + activerecord (7.2.0) + activemodel (= 7.2.0) + activesupport (= 7.2.0) + timeout (>= 0.4.0) + activestorage (7.2.0) + actionpack (= 7.2.0) + activejob (= 7.2.0) + activerecord (= 7.2.0) + activesupport (= 7.2.0) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (6.1.7.8) - concurrent-ruby (~> 1.0, >= 1.0.2) + activesupport (7.2.0) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + base64 (0.2.0) + bigdecimal (3.1.8) bindex (0.8.1) bootsnap (1.18.4) msgpack (~> 1.2) builder (3.3.0) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) concurrent-ruby (1.3.4) + connection_pool (2.4.1) crass (1.0.6) date (3.3.4) + drb (2.2.1) dry-cli (1.1.0) erubi (1.13.0) evil_systems (0.2.0) capybara zeitwerk (>= 2) ffi (1.17.0) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.5) concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) + logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -105,10 +127,9 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) - method_source (1.1.0) mini_mime (1.1.5) mini_portile2 (2.8.7) - minitest (5.24.1) + minitest (5.25.1) msgpack (1.7.2) net-imap (0.4.14) date @@ -120,37 +141,43 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.15.6) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.15.6-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.15.6-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) - public_suffix (5.1.1) - puma (5.6.8) + psych (5.1.2) + stringio + public_suffix (6.0.1) + puma (6.4.2) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.9) + rack (3.1.7) rack-proxy (0.7.7) rack + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.8) - actioncable (= 6.1.7.8) - actionmailbox (= 6.1.7.8) - actionmailer (= 6.1.7.8) - actionpack (= 6.1.7.8) - actiontext (= 6.1.7.8) - actionview (= 6.1.7.8) - activejob (= 6.1.7.8) - activemodel (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.2.0) + actioncable (= 7.2.0) + actionmailbox (= 7.2.0) + actionmailer (= 7.2.0) + actionpack (= 7.2.0) + actiontext (= 7.2.0) + actionview (= 7.2.0) + activejob (= 7.2.0) + activemodel (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) bundler (>= 1.15.0) - railties (= 6.1.7.8) - sprockets-rails (>= 2.0.0) + railties (= 7.2.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -158,42 +185,48 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.8) - actionpack (= 6.1.7.8) - activesupport (= 6.1.7.8) - method_source + railties (7.2.0) + actionpack (= 7.2.0) + activesupport (= 7.2.0) + irb (~> 1.13) + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) regexp_parser (2.9.2) + reline (0.5.9) + io-console (~> 0.5) rexml (3.2.9) strscan rubyzip (2.3.2) - selenium-webdriver (4.9.0) + securerandom (0.3.1) + selenium-webdriver (4.23.0) + base64 (~> 0.2) + logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - sqlite3 (1.7.3) + sqlite3 (2.0.4) mini_portile2 (~> 2.8.0) + sqlite3 (2.0.4-x86_64-darwin) + sqlite3 (2.0.4-x86_64-linux-gnu) + stringio (3.1.1) strscan (3.1.0) thor (1.3.1) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + useragent (0.16.10) vite_rails (3.0.17) railties (>= 5.1, < 8) vite_ruby (~> 3.0, >= 3.2.2) - vite_ruby (3.7.0) + vite_ruby (3.8.0) dry-cli (>= 0.7, < 2) rack-proxy (~> 0.6, >= 0.6.1) zeitwerk (~> 2.2) @@ -202,10 +235,7 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.3.1) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0, < 4.11) + webrick (1.8.1) websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -226,15 +256,14 @@ DEPENDENCIES evil_systems (~> 0.2) jbuilder (~> 2.7) listen (~> 3.3) - puma (~> 5.0) - rails (~> 6.1.3, >= 6.1.3.2) + puma (~> 6.0) + rails (~> 7.0) rexml (~> 3.2.4) selenium-webdriver (~> 4.1) sqlite3 tzinfo-data vite_rails (~> 3.0) web-console (>= 4.1.0) - webdrivers (~> 5.0) BUNDLED WITH - 2.3.5 + 2.5.17 diff --git a/src/methodSubmission.ts b/src/methodSubmission.ts index d4f1e98..0d3f225 100644 --- a/src/methodSubmission.ts +++ b/src/methodSubmission.ts @@ -80,7 +80,8 @@ function getFormData (method: string): FormData { * get, post, put, patch, etc */ function getElementMethod (element: HTMLElement): string { - const method = element.dataset.method ?? 'get' + // eslint-disable-next-line + const method = element.dataset.method || 'get' return method.toLowerCase() } diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 3b83851..916059b 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -21,9 +21,15 @@ export function isSignificantClick (event: MouseEvent): boolean { } export function preventInsignificantClick (event: MouseEvent): void { - if (isSignificantClick(event)) return + // eslint-disable-next-line + const method = (event.target?.getAttribute?.('data-method') || event.target?.form?.method || 'get').toLowerCase() - stopEverything(event) + // Always let "get" pass through. They should be "idempotent" + if (method === 'get') { return } + + if (isInsignificantClick(event)) { + stopEverything(event) + } } export function getCookieValue (cookieName?: string): string | undefined { diff --git a/test/rails/dummy/config/vite.json b/test/rails/dummy/config/vite.json index 22f4a6d..b6106f0 100644 --- a/test/rails/dummy/config/vite.json +++ b/test/rails/dummy/config/vite.json @@ -1,7 +1,9 @@ { "all": { "sourceCodeDir": "app/javascript", - "watchAdditionalPaths": [] + "watchAdditionalPaths": [ + "../../../../dist/" + ] }, "development": { "autoBuild": true,