Giter VIP home page Giter VIP logo

browser's People

Contributors

chris93111 avatar davecheney avatar dependabot[bot] avatar fraggerfox avatar jvatic avatar luna-duclos avatar mislav avatar pascaldekloe avatar regadas avatar siddhant-deepsource avatar tklauser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browser's Issues

Override browser?

On many linux systems, the BROWSER environment variable allows users to specify their default browser, much like the EDITOR or PAGER environment variables.

Would you be open to a PR that adds support for a browser parameter and/or environment variable? I'm happy to contribute Windows and MacOS support for these.

Refresh if URL is already open in browser

Currently, if browser.OpenURL is invoked multiple times, it will open multiple tabs in the web browser. I'd like to be able to maintain a single invocation, whereby the tab is refreshed if it's already open.

OpenURL with data: URL

Hello,

Would it be possible to open the browser with data: URL on Windows? I want to display an image, so have something like data:image/png;base64,.... If I manually paste it in browser address bar (Edge, Firefox, Chrome) it shows the image correctly, but when I execute the command from my go program it pops up "You'll need a new app to open this data" dialog.

Release v1

I see you've switched to go modules by adding go.mod. Could you now release a semver-formatted version of this library? I think that's as easy as git tag v1.0.0 and pushing.

Latest update has caused issue on linux

@davecheney Looks like #21 has cause a regression:

Error: ../../../go/pkg/mod/github.com/pkg/[email protected]/browser_unsupported.go:11:6: openBrowser redeclared in this block
	previous declaration at ../../../go/pkg/mod/github.com/pkg/[email protected]/browser_linux.go:5:30
Error: ../../../go/pkg/mod/github.com/pkg/[email protected]/browser_unsupported.go:15:6: setFlags redeclared in this block
	previous declaration at ../../../go/pkg/mod/github.com/pkg/[email protected]/browser_linux.go:9:20
Error: Process completed with exit code 2.

Allow caller to deal with failure

Please update the "unsupported" case to be more useful. You could provide a browser.IsSupported() that returns true only on supported platforms.

I find the use of build-time handling of different platforms to be overly complex. After reviewing this module and considering writing a pull request, I just went with:

func openBrowser(url string) {
	cmd := "xdg-open"
	args := []string{url}

	switch runtime.GOOS {
	case "darwin":
		cmd = "open"
	case "windows":
		cmd = "rundll32"
		args = []string{"url.dll,FileProtocolHandler", url}
	}
	err := exec.Command(cmd, args...).Start()
	if err == nil {
		return
	}
	fmt.Printf("Failed to launch %s: %v", cmd, err)
	fmt.Printf("Load this URL in your browser:\n    %s\n", url)
}

because it could work on more types of Unix systems and more gracefully fails when assumptions are not met.

Adding support for the BROWSER environment variable to that would be even better.

Stop using CMD with Windows

The current Windows incarnation is brittle:

func openBrowser(url string) error {
r := strings.NewReplacer("&", "^&")
return runCmd("cmd", "/c", "start", r.Replace(url))
}

it survives ampersands, but not other characters:

package main
import "github.com/pkg/browser"
func main() {
   browser.OpenURL("http://example.com?aa bb&cc")
}

better would be to call RunDLL32, no replacer needed. Examples:

rundll32 url,OpenURL "http://example.com?aa bb&cc"
rundll32 url,FileProtocolHandler "http://example.com?aa bb&cc"

https://github.com/skratchdot/open-golang/blob/master/open/exec_windows.go

Or call browser directly via the BROWSER environment variable. This is what
Python does:

import webbrowser
webbrowser.open('http://example.com?aa bb&cc')

https://github.com/python/cpython/blob/master/Lib/webbrowser.py

Or better still would be to call ShellExecuteW on Windows:

https://docs.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew

This is what D does:

import std.process;
void main() {
   browse("http://example.com?aa bb&cc");
}

https://github.com/dlang/phobos/blob/master/std/process.d

and Nim:

import browsers
openDefaultBrowser("http://example.com?aa bb&cc")

https://github.com/nim-lang/Nim/blob/devel/lib/pure/browsers.nim

Worked once then fails with low-level macOS error

๐Ÿ‘‹๐Ÿป

I installed this package, and ran it once and it worked fine. I then came back and tried it again (after making some code changes) and found that no matter what URL I provided to browser.OpenURL the function would error with...

NOTE: I've broken it up over multiple lines for readability.

The application cannot be opened for an unexpected reason, error=
  Error Domain=NSOSStatusErrorDomain 
  Code=-600 "procNotFound: no eligible process with specified descriptor" 
  UserInfo={_LSLine=379, _LSFunction=_LSAnnotateAndSendAppleEventWithOptions}

I've failed to find much useful information on this,
but there is a long thread from another project (which may or may not be useful):
lwouis/alt-tab-macos#704

Package should not log anything by default

Logging things in packages is not the Go way of doing things. the package should never log anything or at least have a way to disable it. IE i get these logs when I use the package on Debian
"Icon theme "gnome" not found.
Icon theme "ubuntu-mono-dark" not found.
Icon theme "Mint-X" not found.
Icon theme "elementary" not found.
Icon theme "gnome" not found."

file:///tmp/browser.1293014077.html ERR_FILE_NOT_FOUND

I use it like this:

	request, err := http.NewRequest("POST", login_url, strings.NewReader(formData.Encode()))
	if err != nil {
		return err
	}
	request.Header.Set("Referer", login_url)
	request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	response, err := client.Do(request)
	if err != nil {
		return err
	}
	fmt.Printf("status code POST: %d\n", response.StatusCode)
	browser.OpenReader(response.Body)

The file /tmp/browser.1293014077.html contains the html.

But the browser seems to not find the file.

I use Chromium on Ubuntu Linux

image

My Pixel 5a running Android 13 cannot find a web browser?

Howdy all y'all,

My Pixel 5a running Android 13 cannot find a web browser.

My Android browser is NOT one of these (xdg-open chrome google-chrome firefox). I get something like these messages:

'fails exec: "xdg-open": executable file not found in $PATH'
'fails exec: "chrome": executable file not found in $PATH'
'fails exec: "google-chrome": executable file not found in $PATH'
'fails exec: "firefox": executable file not found in $PATH'

Does anyone know what it is?

I look forward to hearing from you,
Dale

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.