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

feat(android): enable loading of assets outside of the content web asset directory #6301

Merged
merged 4 commits into from
Feb 21, 2023

Conversation

carlpoole
Copy link
Member

Adds an override option for the RouteProcessor to allow Portals to request a route outside of the assetPath location. EG: a Portal at /assets/mywebapp/index.html wants to load an image at /assets/sharedimages/fish.jpg

Example usage in Portals:

// If AssetMap contains this virtual route, reroute to shared assets location
assetLoop@ for ((mapName, assetMap) in assetMaps) {
    if (path != null) {
        if(path.startsWith(assetMap.virtualPath)) {
            val assetMapObj = assetMaps[mapName]
            if (assetMapObj != null) {
                var trimmedPath = path.replace(assetMap.virtualPath,assetMapObj.getAssetPath())
                if (trimmedPath.startsWith("/")) {
                    trimmedPath = trimmedPath.drop(1)
                }

                processedRoute.path = trimmedPath
                processedRoute.isAsset = true
                processedRoute.isIgnoreAssetPath = true
                break@assetLoop
            }
        }
    }
}

@carlpoole carlpoole merged commit 364497d into main Feb 21, 2023
@carlpoole carlpoole deleted the android-asset-routing branch February 21, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants