Merge pull request #1336 from umap-project/shared-edit-url

Redirect to canonical when URL contains the ?edit parameter
This commit is contained in:
Yohan Boniface 2023-09-27 07:17:29 +02:00 committed by GitHub
commit 677fd3d982
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -264,7 +264,14 @@ L.U.Map.include({
this.onceDataLoaded(function () {
const slug = L.Util.queryString('feature')
if (slug && this.features_index[slug]) this.features_index[slug].view()
if (L.Util.queryString('edit')) this.enableEdit()
if (L.Util.queryString('edit')) {
if (this.hasEditMode()) this.enableEdit()
// Sometimes users share the ?edit link by mistake, let's remove
// this search parameter from URL to prevent this
const url = new URL(window.location)
url.searchParams.delete('edit')
history.pushState({}, '', url)
}
if (L.Util.queryString('download')) this.download()
})

View file

@ -94,6 +94,8 @@ def test_owner_permissions_form(map, datalayer, live_server, login):
".datalayer-permissions select[name='edit_status'] option:checked"
)
expect(option).to_have_text("Inherit")
# Should have been removed since page load
assert "edit" not in page.url
def test_map_update_with_editor(map, live_server, login, user):