0

I have this link http://localhost:5000/index.html?cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp how can i get this part cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp only?

   let location_url = window.location.pathname;
            let new_url = '';
            console.log("location_url.charAt( 0 ): ",location_url.charAt( 0 ))
            console.log("location_url.slice( 1 ): ",location_url.slice( 1 ))
            if( location_url.charAt( 0 ) === '/' )
               new_url = location_url.slice( 1 );
            console.log(new_url)
user14823468
  • 101
  • 13
  • 2
    Does this answer your question? [How do I split a string, breaking at a particular character?](https://stackoverflow.com/questions/96428/how-do-i-split-a-string-breaking-at-a-particular-character) – imjared Jun 02 '21 at 15:25

1 Answers1

2

You can do like this :

// Get your url string
var fullURL = window.location.href;
// Build an URL from the string
var URL = new URL(fullURL);
// Extract the data you are looking for
var result = URL.searchParams.toString();
heythomas
  • 36
  • 3