Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes the MQTT topics vastly easier to understand. See #102 for more info. BREAKING CHANGE: Creates duplicated entries for all existing entities, as the ids have changed
- Loading branch information
Showing
7 changed files
with
45 additions
and
20 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
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
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
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,17 @@ | ||
import { makeId } from './id'; | ||
|
||
describe('makeId', () => { | ||
const idRegex = /^[a-z1-9-]+$/; | ||
|
||
it('should convert inputs to lower case', () => { | ||
expect(makeId('ABC-def123')).toMatch(idRegex); | ||
}); | ||
|
||
it('should convert colons to dashes', () => { | ||
expect(makeId('ble-84:87:ad:ef')).toMatch(idRegex); | ||
}); | ||
|
||
it('should convert underscores to dashes', () => { | ||
expect(makeId('bluetooth-classic_129-1-1')).toMatch(idRegex); | ||
}); | ||
}); |
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,7 @@ | ||
import slugify from 'slugify'; | ||
|
||
export function makeId(input: string): string { | ||
return slugify(input, { | ||
lower: true | ||
}).replace(/[_:]/g, '-'); | ||
} |