Last-Order / Minyami

A lovely video downloader for HLS videos
GNU General Public License v3.0
561 stars 37 forks source link

#72 break same of the usage #78

Closed climba03003 closed 3 years ago

climba03003 commented 3 years ago

Basic Information

Describe the bug

72 break the below usage

Full List of breaking example

Local File Usage host: ./foo.m3u8 host: foo.m3u8

~~M3U8 File which use file name only host: https://test.com/foo.m3u8 path: foo.key~~

Reason Behind new URL parser only accept full URL.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Same as before. Captured from version 4.2.1 image

Screenshots image

fireattack commented 3 years ago

I don't understand the second example.

M3U8 File which use file name only
host: https://test.com
path: foo.key

This won't work before 4.2.2 either. It will just return "https://foo.key".

climba03003 commented 3 years ago

I don't understand the second example.

M3U8 File which use file name only
host: https://test.com
path: foo.key

This won't work before 4.2.2 either. It will just return "https://foo.key test2.js:18".

It should works because I have used the file like this before. See the last condition. It will join host and path and return https://test.com/foo.key https://github.com/Last-Order/Minyami/blob/d6c9e3bce24b6996e56eb59d2d7a29653a9c500e/src/utils/common.ts#L15

fireattack commented 3 years ago

..which exactly will return https://foo.key.

Welcome to Node.js v12.20.0.
Type ".help" for more information.
> host = 'https://test.com'; path = 'foo.key';
'foo.key'
> host.match(/(.+\/)/)[1]
'https://'
> host.match(/(.+\/)/)[1] + path
'https://foo.key'
>
climba03003 commented 3 years ago

..which exactly will return https://foo.key.

Welcome to Node.js v12.20.0.
Type ".help" for more information.
> host = 'https://test.com'; path = 'foo.key';
'foo.key'
> host.match(/(.+\/)/)[1]
'https://'
> host.match(/(.+\/)/)[1] + path
'https://foo.key'
>

I just simplified too much for the host. Will always contain something.m3u8 in the end. host: https://google.com/foo.m3u8 image

fireattack commented 3 years ago

OK. This case isn't broken though. >4.2.2 can return the same thing.

function buildFullUrl2(host, path) {
    return new URL(path, host).href;
}
console.log(buildFullUrl2("https://google.com/a.m3u8", "foo.key"))

// https://google.com/foo.key
fireattack commented 3 years ago

Because you joined it in wrong order. host is the second arg of URL()

climba03003 commented 3 years ago

Because you joined it in wrong order

I double check it and see the problem. Then only the local path problem exist.