Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinterpret nextcloud internal links #285

Open
rgon opened this issue Dec 25, 2021 · 2 comments
Open

Reinterpret nextcloud internal links #285

rgon opened this issue Dec 25, 2021 · 2 comments

Comments

@rgon
Copy link

rgon commented Dec 25, 2021

ENHANCEMENT

It'd be nice if the app detected links to the same nextcloud instance: i.e. to a file or directory https://yourservercloud.tld/f/00000000 or to any other subdirectory (essentiallyNEXTCLOUDURL/.*) and redirected to them instead of embedding the result.

Actual behaviour

If an embedded website contains such a link and the user accesses it, there'll be a child Nextcloud GUI instance inside the parent Nextcloud instance, which is confusing, makes little sense and can be repeated indefinitely.

Expected behaviour

Any link inside the iframe which targets the current nextcloud instance causes the parent website to redirect to that URL.

Usage case in which

Embedding the URL of an app running on a subdomain which saves its files inside a nextcloud-shared directory and has a link to the share to find it easier. External, private apps which use nextcloud as a backend.

@rgon
Copy link
Author

rgon commented Dec 25, 2021

Possible implementation

To commit injs/external.js. Works in the Developer Options console in Firefox 95. However, needs to wait for the page to load (usually not fast). Would be great if we could catch the unload iframe event (but we cannot bind to it because it'll initially be a cross-origin domain.

The value however does seem to change instantly, so a mutation observer may work? (alert(document.getElementById('ifm').contentWindow.location.href) works).

let ifr = document.getElementById('ifm');
ifr.onload = function () {
    try {
        let ifrLocation = ifr.contentWindow.location;
        if (ifrLocation.hostname.match(window.location.hostname)) {
            window.location.href = ifrLocation.href;
        }
    } catch (e) {
        // Ignore error: means the iframe is in another domain and CORS prohibits reading the URL
    }
};

@meichthys
Copy link

@rgon you can follow the suggestion here to remove the header for an external site:
nextcloud/deck#2840 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants