intersection between line segments - narrowed precondition
The arbitrary line can be expressed as y = a*x+b (assuming it's not parallel to the y axis). 

If the other line is parallel to the y axis then you can simply fill in the x coordinate of any point on the line into the formula of the first line. Then you can check whether they intersect by ensuring the result lies between the endpoints of the second line.

For the second line parallel to the x axis you just flip the x and y coordinates.