Application.OpenURL - 399 character limit on Windows

Hello

We need to open a webpage which has a very long URL string (456 characters).

Application.OpenURL works fine on the Mac stand alone, but the Windows version fails.

We did a test application in which the length of the URL string was variable and found that the Windows stand alone has a limit of 399 characters. After that it does not work.

This is not a Windows related problem because we created another application using other tool and it works fine.

Any suggestion on how to solve this problem?

Thank you

Our main Windows developer, Ignas Ziberkas, has looked at this and not been able to reproduce it. Please can you file a bug report about this? Ignas has asked for you to mark it for his attention specifically and also that you include the version of Windows and the browsers that show the bug.

Ready

The way to replicate the problem is pretty simple.

Just assign the attached script to the camera on a simple scene and run the windows stand alone version.

Thank you

314747–11105–$test_131.js (1.07 KB)

The problem is also present when running the project from within the editor (Unity for Windows).

ok, if found it. In one word - don’t even ask ;-).
It will be fixed in 3.0, for now can you just stick with shorter url?

Hello Alexey

The Beta 3.0 has this fixed, thanks.

However, I have been trying to convert a few baKno games into the Beta 3.0 but there are so many changes needed (like the default font) and obstacles (especially with new physics) that I cannot continue converting as it is.

Is there a way to fix the current 2.6 to generate a windows build that opens long URL’s ?

use shorter urls by having the GET data you potentially send through having shorter data lengths?

the alternative is having a fake html in the same folder as your game for example which you generate through file.io yourself which contains the actual target and sets the document.location onload through JS and then openurl that html

Thanks Dreamora

Weird workaround but it works! :smile:

Glad it worked :slight_smile:

Yeah I know its a wierd one and I at first didn’t even think about it till I thought about ways for “redirection” within the browser itself.

Cough TinyURL.com Cough

tinyurl etc are an option if the url is static. if it changes due to parameters etc its no option :wink:

Actually they have a public API where you can shorten a string. I wrote how to do it at one point… Okay I found it. It’s something like this

    // Replaces a long url with a short redirect
    internal static IEnumerator TinyURL( string longURL, UnityEngine.Events.UnityAction<string> redirect ) {
        WWWForm form = new WWWForm();
        form.AddField( "url", longURL );
        using ( UnityWebRequest www = UnityWebRequest.Post( "https://tinyurl.com/api-create.php", form ) ) {
            yield return www.SendWebRequest();
            if ( string.IsNullOrEmpty( www.error ) ) {
                Debug.Log( "Redirect success" );
                redirect( www.downloadHandler.text );
                yield break;
            }
            else
                Debug.LogError( "Redirect error " + www.error );
        }
        redirect( null );
    }