Mahdi Ghiasi
Mahdi Ghiasi

Reputation: 15301

Which Character should I use to separate some URLs?

I have some URLs, like these:

http://stackoverflow.com/questions/ask
http://example.com/Hello/EveryBody/?page=5
http://another.example.com/GoodBye.html?q=me%20%40%20%3Cstackoverflow%3E%20!%3B

I'm getting URLs from user, and I want to put them in one string and send them to C# Server (with jQuery ajax method, by GET request).

(For example, if I had numbers instead of URLs, I could use ; for separation of numbers -> 123;234;2012;4;0;99... But there are URLs now...)

So, what is the best character to separate URLs?

Upvotes: 5

Views: 3678

Answers (1)

Polyov
Polyov

Reputation: 2311

Use the pipe | or vertical bar character. encodeURIcomponent will encode a vertical bar as %7C.

I recommend encoding all your URLs, then concatenating them into one string with vertical bars in between. That way, in your C# code, you can find the vertical bars, then use their positions to regex out the URLs.

Upvotes: 5

Related Questions