Skip to content

Feat: open files with relative path #232

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

Closed

Conversation

singalhimanshu
Copy link
Contributor

Now we can open files directly by running amfora file.gmi rather than
doing amfora file:///absolute/path/to/file.gmi

Solve #231

Now we can open files directly by running `amfora file.gmi` rather than
doing `amfora file:///absolute/path/to/file.gmi`
Copy link
Owner

@makew0rld makew0rld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this PR.

Checking for specific protocols as you have done will not work. For example, you have missed https://. But more importantly, the user could be using any protocol at all, thanks to the features Amfora has like proxying.

A better solution is to check for ://. If that's missing, then check if the file exists, just passing the argument as is. Absolute or relative paths can be handled the same, and so it doesn't need to be checked for that. If the file exists, convert to a file:// URL and pass it along. If the file doesn't exist, pass it along unchanged, as it's maybe a domain like geminispace.info.

Let me know when you've made these changes (by comment or requesting a review), and I'll take a look again.

@singalhimanshu
Copy link
Contributor Author

singalhimanshu commented May 26, 2021

Sorry for the delay, I couldn't get any spare time. This might take some time if that is okay.

@makew0rld
Copy link
Owner

No worries. Just let me know if you can't continue with this later for whatever reason, and I can take it over.

justjosias added a commit to justjosias/amfora that referenced this pull request Sep 28, 2021
Local files can now be loaded by relative path, rather than the
whole path preceded by the `file://` scheme indicator. It first
checks whether or not the requested URL has a scheme (by checking
for `://` in the URL), but also allows making intention known by
specifying `./` or `../` before the URL, closely matching the
behavior of Firefox.

This borrows code from @singalhimanshu's PR (makew0rld#232).

Resolves makew0rld#231
justjosias added a commit to justjosias/amfora that referenced this pull request Sep 28, 2021
Local files can now be loaded by relative path, rather than the
whole path preceded by the `file://` scheme indicator. It first
checks whether or not the requested URL has a scheme (by checking
for `://` in the URL). If not, it checks to see if the file
exists before opening. It also allows making intention known by
specifying `./` or `../` before the URL, closely matching the
behavior of Firefox.

This borrows code from @singalhimanshu's PR (makew0rld#232).

Resolves makew0rld#231
justjosias added a commit to justjosias/amfora that referenced this pull request Sep 28, 2021
Local files can now be loaded by relative path, rather than the
whole path preceded by the `file://` scheme indicator. It first
checks whether or not the requested URL has a scheme (by checking
for `://` in the URL). If not, it checks to see if the file exists
before opening. It also allows making intention known by
specifying `./` or `../` before the URL, closely matching the
behavior of Firefox.

This borrows code from @singalhimanshu's PR (makew0rld#232).

Resolves makew0rld#231
@makew0rld
Copy link
Owner

Fixed by #257. Thanks for your work though!

@makew0rld makew0rld closed this Dec 8, 2021
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.

2 participants