도메인을 따라 URL을 추출하려고했습니다. 이 question에 따르면 window.location.pathname
을 호출하여 가능하지만 내 URL에 http://domain:host/something#random=123
은 #
이후의 모든 것을 삭제합니다. 분할 또는 정규식보다 더 좋은 점이 있습니까? 코드에서Javascript는 URL에서 #을 무시합니다.
:
window.location.pathname("http://domain:host/something#random=123")
반환 /something
원하는 동작 :
window.location.unknownMethodToMe("http://domain:host/something#random=123")
사전에 /something#random=123
감사를 반환해야합니다.
https://developer.mozilla.org/en-US/docs/Web/API/Location#Examples – epascarello