jaizendra-netizen / linkedin-url-normalizer
PHP CLI and library: reshape LinkedIn profile URLs in a CSV into one canonical text form, classify each row and list rows that point at the same profile. Text only, no network.
Package info
github.com/jaizendra-netizen/linkedin-url-normalizer
Type:project
pkg:composer/jaizendra-netizen/linkedin-url-normalizer
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-30 05:52:58 UTC
README
PHP command line tool and library. Give it a CSV of LinkedIn profile links, one per row, and it reshapes each one into a single text form and sorts every row into a class. It works on text only: no network call is made, it does not check that a profile exists, and it does not look at who owns it. The steps run in this order: (1) trim the cell; (2) add https:// when there is no scheme (http:// is rewritten to https://, any other scheme such as ftp:// is not linkedin); (3) lower-case the host, which must be exactly linkedin.com, www.linkedin.com or a two-letter country sub-domain such as xx.linkedin.com (a port, a user name or any other host is not linkedin); (4) the path must start with /in/ (any letter case) followed by a slug made of letters, digits, hyphen, percent signs and underscore; (5) everything after the slug is dropped: more path segments, a query string, a fragment and a trailing slash. The canonical form is https://www.linkedin.com/in/ followed by the slug exactly as typed, so the slug keeps its letter case. Classes: already canonical (the cell already was that text), normalised (the cell changed), company page (path starts with /company/), other linkedin path (any other path on a LinkedIn host), not linkedin, bad slug (an empty slug or a character outside the list above) and empty. The report gives the rows read, the count and share of each class (1 decimal), up to 5 examples of each class that is not already canonical (row id, input > output), and the duplicates: canonical values seen on 2 or more rows, compared with the slug in lower case, as groups of row ids (the first 10 groups, largest group first, then by value). It only reshapes text, it keeps the slug's letter case as typed, and two rows in one duplicate group may still be two different people if the slug is not the one you meant.
Part of the OneGTMLab free GTM tools. Background on the idea: Aimfox.
Install
composer require jaizendra-netizen/linkedin-url-normalizer
Use
Input is a CSV with the columns row_id and url. Column names are matched without regard to case and may be in any order. A cell with line breaks or commas must be in double quotes. A duplicate row_id is an error and names the id. Option --out FILE writes row_id, url, canonical and class for every row to FILE (CSV) and says where it was written. A duplicate row_id, an empty row_id, a missing column, a row with the wrong number of cells or a file with no rows exits 1 with a message; an unreadable file, an unknown option, a missing argument or a file that cannot be written exits 2.
$ php bin/linkedin-url-normalizer sample.csv
rows read: 12
already canonical: 1 (8.3%)
normalised: 5 (41.7%)
company page: 1 (8.3%)
other linkedin path: 1 (8.3%)
not linkedin: 1 (8.3%)
bad slug: 2 (16.7%)
empty: 1 (8.3%)
examples (first 5 of each class that is not already canonical, row id: input > output)
normalised:
r02: linkedin.com/in/beta-two/ > https://www.linkedin.com/in/beta-two
r03: http://uk.linkedin.com/in/gamma-three?trk=abc > https://www.linkedin.com/in/gamma-three
r04: https://www.linkedin.com/in/Alpha-One/details/experience/ > https://www.linkedin.com/in/Alpha-One
r10: www.linkedin.com/in/beta-two#about > https://www.linkedin.com/in/beta-two
r11: https://www.linkedin.com/in/epsilon-five?utm_source=x > https://www.linkedin.com/in/epsilon-five
company page:
r05: https://www.linkedin.com/company/example-co > (no canonical form)
other linkedin path:
r06: https://www.linkedin.com/jobs/view/123 > (no canonical form)
not linkedin:
r07: https://example.com/in/alpha-one > (no canonical form)
bad slug:
r08: https://www.linkedin.com/in/delta.four > (no canonical form)
r12: https://www.linkedin.com/in/ > (no canonical form)
empty:
r09: (empty) > (no canonical form)
duplicates (same canonical value, slug compared in lower case, on 2 or more rows): 2 groups
https://www.linkedin.com/in/alpha-one: r01, r04
https://www.linkedin.com/in/beta-two: r02, r10
Test
php tests/run.php
Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.