-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-130719 / 25.04 / UI Global Search passes "undefined" url path to …
…Docs Hub (#10533) * NAS-130719: UI Global Search passes "undefined" url path to Docs Hub * NAS-130719: PR Update * NAS-130719: PR update * NAS-130719: PR Update
- Loading branch information
1 parent
c578962
commit 974607f
Showing
5 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
43 changes: 43 additions & 0 deletions
43
src/app/modules/global-search/helpers/extract-version.spec.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { extractVersion } from './extract-version'; | ||
|
||
describe('extractVersion', () => { | ||
it('should extract the version "24.10" from "TrueNAS-SCALE-24.10.0-MASTER-20240324-065034"', () => { | ||
const result = extractVersion('TrueNAS-SCALE-24.10.0-MASTER-20240324-065034'); | ||
expect(result).toBe('24.10'); | ||
}); | ||
|
||
it('should extract the version "24.10" from "24.10-BETA.1-INTERNAL.7"', () => { | ||
const result = extractVersion('24.10-BETA.1-INTERNAL.7'); | ||
expect(result).toBe('24.10'); | ||
}); | ||
|
||
it('should return undefined for a string with no matching version pattern', () => { | ||
const result = extractVersion('NoVersionHere'); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it('should extract the version "1.2" from "1.2.3-alpha"', () => { | ||
const result = extractVersion('1.2.3-alpha'); | ||
expect(result).toBe('1.2'); | ||
}); | ||
|
||
it('should extract the version "10.20" from "v10.20.30-beta-release"', () => { | ||
const result = extractVersion('v10.20.30-beta-release'); | ||
expect(result).toBe('10.20'); | ||
}); | ||
|
||
it('should extract the version "0.1" from "v0.1.0-RC1"', () => { | ||
const result = extractVersion('v0.1.0-RC1'); | ||
expect(result).toBe('0.1'); | ||
}); | ||
|
||
it('should return undefined for a string "Version-1-2-3"', () => { | ||
const result = extractVersion('Version-1-2-3'); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it('should extract the version "2.5" from "2.5-rc.1-build.2023"', () => { | ||
const result = extractVersion('2.5-rc.1-build.2023'); | ||
expect(result).toBe('2.5'); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function extractVersion(version: string): string | undefined { | ||
return version.match(/(\d+\.\d+)(?:\.\d+)?/)?.[1]; | ||
} |
This file contains 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
This file contains 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