Better URL paths in O3
Hi, all!
It’s about time we spoke about URL paths in O3. Currently, because of the way URL paths are set up in O3, we’ve ended up with a situation where URL encoded characters appear in the URL path. This is not ideal, and we should fix it. Examples of URL paths in O3 that don’t conform to best practice are:
-
Vitals %26 Biometrics - for the vitals and biometrics page.
-
Patient Summary and Test Results - for the summary and test results pages.
-
Allergies, Medications, Programs, and so on.
Best practice dictates that URL paths should be as clean as possible. This means that they should be as short as possible, and should not contain any URL encoded characters. URLs should not contain special characters like spaces and ampersands. Using dashes or underscores allows for consistency and readability.
Possible ideal URL paths for the above examples are:
-
vitals-and-biometrics
-
patient-summary
-
test-results
-
allergies, and so on.
Technically, it involves changing code in four places:
-
DashboardExtension component in the Patient Chart common lib openmrs-esm-patient-chart/packages/esm-patient-common-lib/src/dashboards/DashboardExtension.tsx at main · openmrs/openmrs-esm-patient-chart · GitHub
-
The
path
property indashboard.meta
files, which determines the URL path. -
Related to
path
above, thepath
property of anymeta
definitions in theroutes
registry file. -
The URL segment in the Breadcrumbs menu. This is governed by the
key
parameter of thetitle
property in theregisterBreadcrumbs
function openmrs-esm-patient-chart/packages/esm-patient-chart-app/src/index.ts at main · openmrs/openmrs-esm-patient-chart · GitHub.
How will this affect you?
Any URLs that point to the above paths will break. This includes URLs in code and URLs in tests (both unit and e2e tests). I plan on fixing any regressions that may arise from this change, but I can’t guarantee that I’ll be able to fix all of them (especially for code that doesn’t exist in our key repositories Key repositories – O3 Docs).
If you have any URLs that point to the above paths, please look out for my pull request, which I will link to this talk post. I will also communicate about the change in the #openmrs3 channel on Slack.
Happy coding!