Skip to content

Latest commit

 

History

History
15 lines (10 loc) · 425 Bytes

build-urls-with-window-location.md

File metadata and controls

15 lines (10 loc) · 425 Bytes

Build URLs with Window Location

Want to build URLs with JavaScript? Try thewindow.location object.

This came from a React.js project we're working on. It uses ES6 template string interpolation, which isn't necessary but definitely is nice:

`${window.location.protocol}//${window.location.host}/posts/${this.props.postID}/edit`

Which becomes:

"https://secret-project.com/posts/42/edit"