0

My url (localhost) :

http://localhost/nana-appication/public/

or

http://localhost/nana-appication/public/home

My url (server) :

http://dsp.nana.com/public/

or

 http://dsp.nana.com/public/home

I want to eliminate :

Localhost : http://localhost/nana-appication/

Server : http://dsp.nana.com/

So when I run console.log or alerts in javascript, a result like this :

localhost or server :

public/

or

public/home

Thank you

2 Answers 2

1

Try this:

var a = 'http://localhost/nana-appication/public/home';
var b = a.replace(a.split(/public.*/)[0],'');
console.log(b); // 'public/home'

(First you explode the string by '/public.*', then replace first part with empty string).

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

Comments

0

I think this is a repeat of https://stackoverflow.com/a/736970/5741308 (which is brilliant).

Read down as a later answer addressed relative paths and IE strangeness.

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.