Skip to content

Commit

Permalink
fix(final-screen) CurrentPageMatches use current path
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre PÉRONNET <[email protected]>
  • Loading branch information
holyhope committed Apr 16, 2024
1 parent 68eca8f commit 59a73f2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions login/chrome/screen_final.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"
"net/http"
"net/url"

"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/network"
"github.com/chromedp/chromedp"
"golang.org/x/oauth2"
Expand All @@ -25,17 +25,24 @@ func (s *finalScreen) String() string {
}

func (s *finalScreen) CurrentPageMatches(ctx context.Context) bool {
var nodeIDs []cdp.NodeID
var currentLocation string

if err := chromedp.Run(ctx,
chromedp.NodeIDs(`#popin_tc_privacy_button`, &nodeIDs, chromedp.ByID, chromedp.AtLeast(0)),
chromedp.Location(&currentLocation),
); err != nil {
errorLogger(ctx).Printf("run: %v\n", err)

return false
}

return len(nodeIDs) > 0
currentURL, err := url.Parse(currentLocation)
if err != nil {
errorLogger(ctx).Printf("parse current location: %v\n", err)

return false
}

return currentURL.Path == "/home"
}

type InvalidTokenError struct {
Expand Down

0 comments on commit 59a73f2

Please sign in to comment.