apache / apache/cordova-plugin-file

Resolve URLs with more than one colon fails

Open
#507 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
744
Forks
754
Avg merge
3d 4h
Merged PRs (30d)
1

Description

# Bug Report
If I try to resolve something like `http://localhost:8000/index.html` i get an `ENCODING_ERR` because of these lines:
https://github.com/apache/cordova-plugin-file/blob/3e588763a5e49ea441a996bf4139efdf6f6a5f11/www/resolveLocalFileSystemURI.js#L55-L62

When i disable this code like i did here https://github.com/GitToTheHub/cordova-plugin-file/pull/1, I can finally resolve urls like `http://localhost:8000/index.html`. Do someone know why these lines of code exist and if it's safe to remove them? I would make an PR without these lines, or by allowing maximum 2 colons.

## Problem

### What is expected to happen?

URLs like `http://localhost:8000/index.html` should resolve

### What does actually happen?

The API throws `ENCODING_ERR`

## Information
Just run the app in a browser and try to resolve `http://localhost:8000/index.html`.

### Command or Code
```
resolveLocalFileSystemURL(
"http://localhost:8000/index.html",
(fileEntry) => {
alert("URL successfully resolved! name=" + fileEntry.name);
},
(fileError) => {
alert("URL could not be resolved: " + fileError.code);
}
);

(Something to note: When i try to resolve a wrong url with my changed code, to allow more than one colon, the errorcallback will not be invoked)
```

### Environment, Platform, Device
Browser platform, but this issue will occure in any other platform also.

## Checklist

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start with www/resolveLocalFileSystemURI.js at lines 55-62 and reproduce the documented resolveLocalFileSystemURL call for http://localhost:8000/index.html in a browser. Determine why multiple colons produce ENCODING_ERR, preserve the error callback for invalid URLs, and verify that valid URLs with a port resolve successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.