Skip to content

Try to avoid "...//state.txt" URLs for replication. - #320

Open
amandasaurus wants to merge 1 commit into
osmcode:masterfrom
amandasaurus:repl-dont-double-slash
Open

amandasaurus wants to merge 1 commit into
osmcode:masterfrom
amandasaurus:repl-dont-double-slash

Conversation

@amandasaurus

Copy link
Copy Markdown
Contributor

Previously, for a base URL of example.com/area-updates/ the code would look for example.com/area-updates//state.txt" etc. This change will make it request example.com/area-updates/state.txt`. It now doesn't “double slash”.

This will ensure providers of OSM data updates (e.g. Geofabrik) will see consistent URLs regardless of small typing changes.

This change is inspired by Postel's Law: “be conservative in what you send, be liberal in what you accept”.

Previously, for a base URL of "example.com/area-updates/" the code
would look for "example.com/area-updates//state.txt" etc. This change
will make it request "example.com/area-updates/state.txt". It now
doesn't “double slash”.

This will ensure providers of OSM data updates (e.g. Geofabrik) will see
consistent URLs regardless of small typing changes.
@amandasaurus
amandasaurus force-pushed the repl-dont-double-slash branch from 9c83fb5 to 41267ea Compare October 5, 2026 13:25

@lonvia lonvia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me in general. Unfortunately, merging is currently stuck on rather exotic CI fails of the Windows builds, which I have yet no idea how to fix.

# Try to avoid calling `example.com/area-updates//state.txt`
baseurl_wo_slash = self.baseurl
while baseurl_wo_slash[-1] == "/":
baseurl_wo_slash = baseurl_wo_slash[:-1]

@lonvia lonvia Oct 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to do that in __init__ while assigning self.baseurl so it is only done once. (The variable could be overwritten later in theory but that would be unintended use, so safe to ignore.)

Also, you should use the endswith() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants