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

Multiple disk output is wrong #110

Open
UshakovVasilii opened this issue Jun 5, 2014 · 0 comments
Open

Multiple disk output is wrong #110

UshakovVasilii opened this issue Jun 5, 2014 · 0 comments

Comments

@UshakovVasilii
Copy link

About code:

function parseHddTempOutput(txt, sep) {
    let hddtemp_output = [];
    if (txt.indexOf((sep+sep), txt.length - (sep+sep).length) >= 0)
    {
        hddtemp_output = txt.split(sep+sep);
    }
    else
    {
        hddtemp_output = txt.split("\n");
    }

My netcat output:

[ushakov@ushakov-pc ~]$ nc localhost 7634
|/dev/sda|KINGSTON SV300S37A120G|31|C||/dev/sdb|TOSHIBA DT01ACA200|36|C|

I think something wrong in first condition.

txt.length = 72
txt.length - (sep+sep).length = 70
So txt.indexOf((sep+sep), txt.length - (sep+sep).length) = txt.indexOf('||', 70) = -1 after that fist disk is outputted only.

I think should be something like:

if (txt.indexOf(sep+sep) > 0)

instead of:

if (txt.indexOf((sep+sep), txt.length - (sep+sep).length) >= 0)

How do you think?
Thank you!

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

No branches or pull requests

1 participant