Skip to content

ShareViewController transfers too many '/' in file url #79

@MichaelMaenner

Description

@MichaelMaenner

Describe the bug
If i share a file, e.g. an image, the function createSharedFileUrl of the ShareViewController passes to many /

file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2F1C0BA5F1-DE70-123D-8435-1F125779A3CE%2F%2FIMG_0029.PNG
file:///private/var/mobile/Containers/Shared/AppGroup/1C0BA5F1-DE70-123D-8435-1F125779A3CE//IMG_0029.PNG

So, i get file:/// and //filename.PNG

I can remove the + "/" + from inside the createSharedFileUrl which helps with the // in front of the filename, but i cant figure out how to remove one of the /// without manipulating the file url itself.

To Reproduce
Steps to reproduce the behavior:

  1. Create an Capacitor App with the given send-intent example
  2. Share a File with the App
  3. App cant handle File because of too many /

Expected behavior
The shared file url should look like that:

file%3A%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2F1C0BA5F1-DE70-123D-8435-1F125779A3CE%2FIMG_0029.PNG
file://private/var/mobile/Containers/Shared/AppGroup/1C0BA5F1-DE70-123D-8435-1F125779A3CE/IMG_0029.PNG

Additional context
Currently working with "send-intent": "^3.0.12"

Inside of my Capacitor/Angular App i have added some sort of Workaround for that. Its definitely not pretty, but it works. But i also want to get rid of it.

      try {
        intent.url = intent.url.replaceAll('%2F%2F', '%2F'); // '//' -> '/'
        if (!intent.url.includes('%3A%2F%2F') && intent.url.includes('%3A%2F')) {
          intent.url = intent.url.replace('%3A%2F', '%3A%2F%2F'); // ':/' -> '://';
        }
        const resultUrl = decodeURIComponent(intent.url);
        ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions