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

clean up 'url_host()' mess #856

Closed
jsmeix opened this issue Jun 1, 2016 · 3 comments
Closed

clean up 'url_host()' mess #856

jsmeix opened this issue Jun 1, 2016 · 3 comments

Comments

@jsmeix
Copy link
Member

jsmeix commented Jun 1, 2016

Current rear master.

While I am trying to implement #845
I get totally confused by what 'url_host()' means.

The current url_host() function in global-functions.sh
does not result the hostname in an URL but
it results simply the part after the scheme.

E.g. for

scheme://foo@bar/something/else

url_host() results 'foo@bar' and not only 'foo'
as the name of that function indicates.

I tried to 'fix' that so that the url_host() function
results what its name tells but that lead into mess.

The really bad thing is that some places rely on
this obscure behaviour e.g. in global-functions.sh

        (sshfs)
            mount_cmd="sshfs $(url_host $url):$(url_path $url) $mountpoint -o $options"

because sshfs can be called as

sshfs [user@]host:[dir] mountpoint [options] 

Accordingly as a precondition before implementing #845
I have to first clean up the current 'url_host()' mess.

I think I will do the following to avoid regression:

First I rename the current 'url_host()' function into 'url_user_at_host()'
and replace all calls of that function as needed.

Then I add two new functions 'url_host()' and 'url_user()'
that result what their name tells.

Finally I can use the new functions 'url_host()' and 'url_user()'
to implement #845 (comment) properly.

@jsmeix jsmeix added the cleanup label Jun 1, 2016
@jsmeix jsmeix added this to the Rear future milestone Jun 1, 2016
@jsmeix jsmeix self-assigned this Jun 1, 2016
@jsmeix
Copy link
Member Author

jsmeix commented Jun 1, 2016

I will keep it simpler:

To avoid regressions I will not change any existing functionality.
I will keep the current 'url_host()' function as is.
But I will add explanatory comments that tell
what current 'url_host()' function actually results.

I will add two new functions 'url_hostname()'
and 'url_username()' that result what their name tells.

Then I can use the new functions 'url_hostname()'
and 'url_username()' to implement #845

@jsmeix
Copy link
Member Author

jsmeix commented Jun 1, 2016

In #857 I implemented
what I wrote in #856 (comment)

@jsmeix jsmeix modified the milestones: Rear v1.19, Rear future Jun 1, 2016
@jsmeix
Copy link
Member Author

jsmeix commented Jun 1, 2016

With #857 I consider
this issue as sufficiently fixed (at least for now).

Perhaps in the future we may need additional functions
url_port() and url_password() to support all usual
components of a generic URI of the form

scheme:[//[user[:password]@]host[:port]][/]path

FYI:
I think in
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
the syntax that a generic URI is of the form

scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]

is not fully correct because I think the ':password' part
is optional i.e. I think a URI could contain a plain 'user@'
without a ':password' like

BACKUP_URL=ftpfs://user@host/rear/

cf. #845

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

1 participant