JavaScript Convert relative path to absolute path on Windows? convert relative path to absolute path,convert relative path to

I know of this question: Convert relative path to absolute using JavaScript
But it is about JavaScript that runs in a browser. My JS runs on Windows (WSH).
That means I don't have the following objects: window, document and console. I already figured a few things out:
Since you can use slash (/) instead of a backslash () in a path and you don't need to escape a slash, I'll try to work with / ... I also figured it would be best to remove the trailing slash if there is one.

So here are a couple of things I already figured out:

var currentDir = new ActiveXObject("WScript.Shell").CurrentDirectory.replace(/\\/g, '/'); //current directory with slashes
var root = currentDir.substring(0,2) //e.g. C: or D: (without trailing slash)

There are a couple of of different relative pathes that have to be converted correctly. Just to make sure, here are some examples:

If the script was launched from C:\folder1\folder2\folder3 the paths should be converted accordingly:

/ => C:
/test => C:/test
\test => C:/test
\test\ => C:/test
.. => C:/folder1/folder2
C:\folder1\folder2\folder3\..\folder3-1\test.js => C:/folder1/folder2/folder3-1/test.js
../../test.js => C:/folder1/test.js
D:\ => D:
. => C:/folder1/folder2/folder3
./test => C:/folder1/folder2/folder3/test
.\..\.. => C:/folder1
D:/folder/another folder/file.js/../../other file.js => D:/folder/other file.js

And yeah.. I'm kind of stuck here. I guess this requires some kind of parsing loop, but I just couldn't come up with the solution.
I hope you can help me out here. :/

Answer:1

Angular has these for DOM manipulation but I'm contemplating using jQuery for these functions: closest()/children(). So, Is there an angular function that is identical to jQuery's function closest() ...

Angular has these for DOM manipulation but I'm contemplating using jQuery for these functions: closest()/children(). So, Is there an angular function that is identical to jQuery's function closest() ...

Wasn't quite sure how to title the question. Nonetheless - consider you have the following statement if (messageOne || messageTwo || messageThree || messageFour) { // do something here ... } How ...

Wasn't quite sure how to title the question. Nonetheless - consider you have the following statement if (messageOne || messageTwo || messageThree || messageFour) { // do something here ... } How ...

  1. javascript first value in array
  2. javascript first value in object
  3. javascript first value
  4. javascript first value not null
  5. javascript get first value of object
  6. javascript get first value of array
  7. javascript split first value
  8. javascript find first value in array
  9. javascript remove first value from array
  10. javascript map first value
  11. javascript get first value of map
  12. javascript get first value of dictionary
  13. javascript get first value
  14. javascript reduce first value
  15. javascript get first value of associative array
  16. javascript return first value of array
  17. javascript get first value of json
  18. javascript select first value
  19. javascript get first value of set
  20. javascript dictionary first value

I'm new to JavaScript, and I'm trying to create a simple hide and show div toggle, though it's not working. I'm not sure what the issue is -- I have the div initially display:none, then when the ...

I'm new to JavaScript, and I'm trying to create a simple hide and show div toggle, though it's not working. I'm not sure what the issue is -- I have the div initially display:none, then when the ...

  1. simple jquery toggle
  2. simple jquery toggle accordion
  3. simple jquery toggle menu
  4. simple jquery toggle button
  5. jquery simple toggle show hide
  6. simple toggle switch jquery

As the title says really! You can make rspec print passing tests, instead of just any failing ones; is there a way to make Protractor do the same?

As the title says really! You can make rspec print passing tests, instead of just any failing ones; is there a way to make Protractor do the same?