Giter Club home page Giter Club logo

custom-protocol-detection's People

Contributors

annavernidub avatar ismailhabib avatar kirill-konshin 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

custom-protocol-detection's Issues

Protocol detection in IE11 in Windows 7 doesn't work

Protocol detection in IE11 in Windows 7 doesn't work

Html page:

<html>
<head>
<script src="protocolcheck.js"></script>
</head>
<body>
<script>
protocolCheck('mytest:100:1',
    		function() {
    			console.log("Failure!");
    		}, function() {
    			console.log("Success!");
    		}
    	);
</script>
</body>
</html>

My application successfully launches a new window, but onblur event never happens, so fail callback is always executed.

Uncaught SyntaxError: Lexical declaration cannot appear in a single-statement context

I was using the plugin and it was working fine until we merged it and push to prod. Using the plugin in PROD environment I am having this error:

"Uncaught SyntaxError: Lexical declaration cannot appear in a single-statement context"

Accordingly with Chrome inspector it starts at else if(document.hasFocus())g();else var h=r(window,"focus",(function()

Any suggestion on how to proceed?

I am doing a simple import of your project: import customProtocolCheck from "custom-protocol-check";

Div in example

Currently I managed to make it work in Safari with a tag, should I do it with div as in examples for better compatibility or can keep it? Also, I think index.js file is not in use and should be removed.

In Chrome if user selects the "Remember my choice for all links of this type" check box the fail callback always gets called.

Hi there, first off this js file is really useful, great job on it. I have run across a problem though now that I have implemented it my self. Details below:

Chrome ver. 42.0.2311.90 m / Windows

If a user selects the "Remember my choice for all links of this type" check box in the browser default protocol handler alert from there on when ever the protocolCheck method is called it will always run the fail callback as well as opening the app associated with the protocol handler. I believe this is due to the time out checking on if that dialog opens or not after a certain amount of time, but have not had the opportunity to dig further into the issue.

The failure callback is called even when protocol is defined

If protocol is defined and it is associated with an executable, browser shows an alert in order to accept or deny the execution.

I think that alert causes the timeout to occur so the failure callback is called, instead of the success callback.

Have you checked this?

I am in Google Chrome.

Thanks
Jaime

Firefox Version 64.0

For the Firefox-Version 64.0 the check stopped working.

The Function openUriUsingFirefox should throw an Exception in Lines 85/86 if the protocol is not available, but in this version of firefox did´t.
If I call the protocol in a tab, the connection fails as expected after a short time.

For a workaround the function openUriWithHiddenFrame should work with the timeout of 1second build in. So I check the firefox version and switch it:

if (browser.isFirefox) {
if (getFirefoxVersion() >= 64) {
openUriWithHiddenFrame(uri, failCallback, successCallback);
} else {
openUriUsingFirefox(uri, failCallback, successCallback);
}
} else if ...

Both success and failure callbacks are executed in IE

Steps:

  1. Create and open in IE following index.html file:
<html>
<head>
<script src="protocolcheck.js"></script>
</head>
<body>
<script>
function test() {
	protocolCheck('blablabla', function() { alert("Failure!"); }, function() { alert("Success!"); } );
}
</script>
<button onclick="test()">Test</button>
</body>
</html>
  1. Open file in IE11 (Windows 7)

Expected result:
Failure callback is executed.
Actual result:
Failure and Success callbacks are executed.

Solution:
In openUriWithHiddenFrame function change order of lines in timeout function.
From:

        var timeout = setTimeout(function () {
            failCb();
            handler.remove();
        }, 1000);

to

        var timeout = setTimeout(function () {
            handler.remove();
            failCb();
        }, 1000);

Also, it's better to do the same in detection code for Chrome (openUriWithTimeoutHack function).

Request for OSS license

Hi Ismailhabib,

One of my teams would like to use your custom-protocol-detection library in a project, though is unable to without a specific OSS license being stipulated.
Would you be open to the idea of adding a license like MIT or Apache 2.0 to this project?

Thank you for this fantastic bit of software engineering, sir!

Nothing for Safari

I noticed there isn't anything for safari. So instead I used what Chrome was using and it works perfectly. I would suggest to put this into the package as it was very helpful. Although if the app doesn't exist this is where I am having a problem. So it would be great to have safari support soon.

Firefox 53 not working

Since the release of firefox 53 the openUriUsingFirefox function, iframe.contentWindow.location.href = uri; don't throw any exception anymore.

failCb() is not called and successCb() transport the user to the Windows Store to open an unknown protocol (on windows 10) or nothing on windows <10 & mac.

Do you have any workaround about re-adding firefox support?

Edge and msLaunchUri

This project is amazing!!! I like the way you used onBlur for Chrome.

I'm having a problem with msLaunchUri in Edge on Windows 10 (obviously) but the problem doesn't appear in IE on Win10. In IE it works as designed, calling the success and fail functions properly. But in Edge, nothing happens at all. I've modified your code slightly (as I can't use jquery to call your functions) and here it is:
if (navigator.msLaunchUri) { alert('msLaunchUri is true'); navigator.msLaunchUri(url, function(){ console.log('dwrc protocol found'); }, //success function(){ startAutoDownload(url); } //failure );

The alert fires, so I know the if statement is working. I also can see from the F12 menu that the url value is correct. But the program doesn't launch, nothing gets written to the console, and the download doesn't start. Even though the exact same code works in IE.

Any ideas?
P.S. how do I get the line breaks in my code to show in the post?

Does not work with Safari

Because of browser detection ifs in Safari nothing is launched, neither success nor fail callback:

https://github.com/ismailhabib/custom-protocol-detection/blob/master/protocolcheck.js#L197

    if (navigator.msLaunchUri) { //for IE and Edge in Win 8 and Win 10
        openUriWithMsLaunchUri(uri, failCb, successCb);
    } else {
        var browser = checkBrowser();

        if (browser.isFirefox) {
            openUriUsingFirefox(uri, failCallback, successCallback);
        } else if (browser.isChrome) {
            openUriWithTimeoutHack(uri, failCallback, successCallback);
        } else if (browser.isIE) {
            openUriUsingIEInOlderWindows(uri, failCallback, successCallback);
        } else {
            //not supported, implement please
        }
    }

Instead of commented line a failure callback has to be called or a new, third type has to be introduced.

Moreover the check returns following browser object:

isChrome: false
isFirefox: false
isIE: false
isOpera: false
isSafari: false

Safari version is 10.1.2 (12603.3.8).

Automated tests

This project definitely need automated tests which will check the functionality on various browsers. Manual tests are too error prone and time consuming.

What I have in mind:

  • Something like Selenium WebDriver tests,
  • Which run in the cloud, on various browsers

False positive protocol detection in Firefox after install-uninstall of custom protocol

Steps:

  1. Install custom protocol in the Windows register.
  2. Execute link with the protocol in Firefox and check "remember my choice for ... links".
  3. Uninstall custom protocol from the Windows register.
  4. Execute link with the protocol in Firefox.

Expected result:
Fail callback is executed.
Actual result:
Success callback is executed. Nothing is invoked.

Workaround:
Open "about:preferences#applications" and set your protocol as "Always ask".

Similar issue (see #8) exists also in Chrome (Windows 8 and 10).

my page running in an iframe , onBlur function not run, i have registered with top level window

function openUriWithTimeoutHack(uri, failCb, successCb) {

    var timeout = setTimeout(function () {
        failCb();
        handler.remove();
    }, 	1000);

    //handle page running in an iframe (blur must be registered with top level window)
    var target = window;
   
    while (target != target.parent) {
        target = target.parent;
    }

    var handler = _registerEvent(target, "blur", onBlur);

    function onBlur() {
        clearTimeout(timeout);
        handler.remove();
        successCb();
    }
   
    window.location = uri;
   
}

thanks

Is it possible to wait until browser custom protocol confirmation to be accepted?

When browser is redirected to custom protocol link it shows the custom protocol handler confirmation dialog like this one in Safari:

image

Unfortunately, right now the lib does not capture this, e.g. fires success callback right away when the dialog is shown (assuming that protocol has been handled).

In reality if user refuses to launch the app some extra actions may be needed so we should somehow detect acceptance and fire some callbacks.

Chrome/Edge

Chrome and Edge are still not compatible with a custom handler, i have windows 10.

Firefox, Opera, Safari all work fine.

firefox NS_ERROR_FAILURE

Consider change below. This is because if protocol is registered but app is not there then firefox throws another error e.name==NS_ERROR_FAILURE

if (e.name == "NS_ERROR_UNKNOWN_PROTOCOL") {
            failCb();
}

to

if (e ) {
            failCb();
}

line 187 - url should be uri

 window.protocolCheck = function(uri, failCb, successCb) {
... 
openUriWithMsLaunchUri(url, failCb, successCb);

should be uri, not url - otherwise, edge throws 'url is undefined'

Awesome library. Thank you! I'd buy you a beer if I could.

Need to control timeouts for some browsers

We have applications that are sometimes slow to launch for some users. Having the ability to control the timeouts would be very helpful in these cases.

I'll create a pull request for this.

Thanks!

Nate

Chrome and custom protocol

I'm currently experiencing an issue with Chrome (build 49.0.2623.87) and a custom protocol on both Windows 8 and Windows 10.

The first time the custom protocol is used in Chrome, Chrome shows an External Protocol Request popup that ask if the user wants to 'Launch the Application' and has a check box to 'Remember my choice for all links of this type.' If the check box is selected, Chrome will open the application with the custom protocol links in the future. All fine so far.

Afterwards, if you uninstall the application and custom protocol, the failure callback function isn't called when you try to use the custom protocol. Chrome instead shows a popup 'No apps are installed to open this type of link (CUSTOM PROTOCOL)' and prompts the user to look for an app in the Windows Store. This popup steals the focus.

From my research, I did find a solution that involves editing C:\Users{USERNAME}\AppData\Local\Google\Chrome\User Data\Local State (more details here), but it would be great if this could be handled by custom-protocol-detection.

Success callback

Could you implement a successCb analog to failCb? successCb should be called when the custom protocol has been recognized.

This would help to inform users that the external application has been started.

the bug in Firefox

The function openUriUsingFirefox don't take effect in latest edition Firefox(74.0),however openUriWithHiddenFrame do the work

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.