0

I have a string of a url:

var url = "/_imgs/media/image/Picture%201.png"

When I try to split it lke:

var path = url.split('image/');
console.log(path);

gives:

["/_imgs/media/", "Picture%201.png"]

ok fine, but when I do

console.log(path[1]);

I get:

/Picture%png

What is happening here?

2
  • 1
    That's odd. It seems to work fine for me. Commented Jul 15, 2011 at 6:49
  • Goes OK for me too in chrome - jsfiddle.net/3u2Ad Commented Jul 15, 2011 at 6:50

1 Answer 1

2

It looks like a problem with firebug rather than the javascript. Chrome displays the second console log fine, but firebug misses out the %20 (url encoded space).

Interestingly, if you try:

console.log(path[1].indexOf('2'));

You get 8, which is the correct position. So the variable contains the right data, it's just the console showing it wrong.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.