Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPrzemyslaw Mazur
Courses Plus Student 9,296 PointsHow does the browser know that the text we type in the form field is a username.
I know there is a method used on it. I mean var username = request.url.replace("/", "");. Shouldn't it just replace the / symbol with an empty string and why it doesn't set the username variable to the whole url including "http://port-3000-2rmzgrlbw8.treehouse-app.com/"
1 Answer
Steven Parker
231,236 PointsThe "replace("/", "")
" method does replace the / symbol with an empty string.
If I understand the other question, the rest of the URL is removed because a header is being constructed that only contains a relative path.
Kyle O'Brien
11,873 PointsKyle O'Brien
11,873 PointsIt gets it from the html attribute. So if I gave my search input the name attribute of cook and hit search...
<input type="text" placeholder="Enter a Treehouse username" id="book" name="cook">
I would get something like this:
cook=pizza