Collapse the duplicated URL well-formedness scan into one exported primitive - #2357
Open
jakebromberg wants to merge 1 commit into
Open
Collapse the duplicated URL well-formedness scan into one exported primitive#2357jakebromberg wants to merge 1 commit into
jakebromberg wants to merge 1 commit into
Conversation
…imitive shared/lml-client's safeHttpHostname and apps/backend's hasWireUrlParserDifferential hand-maintained the same <= 0x20 || 0x7f || 0x5c character bar in two arrangements. apps/backend already depends on shared/lml-client, so the scan can live there without inverting the package graph. Extract it as shared/lml-client's exported hasUrlParserDifferentialChar; safeHttpHostname and hasWireUrlParserDifferential both delegate to it, keeping their own names, doc comments, and surrounding trim/no-trim behavior. Closes #2356
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shared/lml-client'ssafeHttpHostnameandapps/backend/utils/album-metadata-projection.ts'shasWireUrlParserDifferentialhand-maintained the same<= 0x20 || 0x7f || 0x5ccharacter bar, just arranged differently (a two-step scan-then-backslash-check vs. a single-pass scan).apps/backendalready depends onshared/lml-client(it importsisSpotifyUrl/isAppleMusicUrlfrom it), so the shared scan can live inshared/lml-clientand be consumed byapps/backendwithout inverting the package graph.shared/lml-client/src/streaming-url-guard.ts's newly exportedhasUrlParserDifferentialChar, exported fromshared/lml-client/src/index.ts.safeHttpHostnamenow calls it instead of open-coding the two-step scan.hasWireUrlParserDifferentialkeeps its exported name and doc comment, and now delegates tohasUrlParserDifferentialChar.isSpotifyUrl/isAppleMusicUrlare untouched — they still go throughsafeHostname, notsafeHttpHostname, so their characterization tests are unaffected.wireUrl's trim semantics andsafeHttpHostname's no-trim/lowercased-hostname behavior are both unchanged; only the scan itself moved.Behavior-preserving by construction: the merged union of
safeHttpHostname's two former steps is exactlyhasWireUrlParserDifferential's single predicate, and both now literally call the same function.Test plan
hasUrlParserDifferentialCharcharacterization tests intests/unit/shared/lml-client/streaming-url-guard.test.tshasWireUrlParserDifferential/wireUrltest file (tests/unit/utils/album-metadata-projection.wire-url.test.ts) pinning the delegation is behavior-preservingnpm run test:unit(525 suites / 9226 tests green)npm run typechecknpm run lint(no new errors; pre-existing warnings only)npm run format:checkCloses #2356