Greenheart / pagecrypt

Password Protected Single Page Applications and HTML files
GNU Affero General Public License v3.0
242 stars 26 forks source link

Simplify clearing of the URL hash after decryption #50

Closed Greenheart closed 8 months ago

Greenheart commented 8 months ago

The following can be simplified, from this:

https://github.com/Greenheart/pagecrypt/blob/4571f6673b45234da4375d946d65f01c9acd9edf/web/decrypt.ts#L41-L44

To this:

const parts = location.href.split('#')
pwd.value = parts[1]
history.replaceState(null, '', parts[0])

This works because location.href.split('#') always returns the href without the URL hash, no matter if it is present or not.