Remove "pws:" prefix from PWS ID
This commit is contained in:
@@ -57,7 +57,7 @@ export interface AdjustmentMethodResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AdjustmentOptions {
|
export interface AdjustmentOptions {
|
||||||
/** The ID of the PWS to use, prefixed with "pws:". */
|
/** The ID of the PWS to use. */
|
||||||
pws?: string;
|
pws?: string;
|
||||||
/** The API key to use to access PWS data. */
|
/** The API key to use to access PWS data. */
|
||||||
key?: string;
|
key?: string;
|
||||||
|
|||||||
@@ -221,8 +221,8 @@ export const getWateringData = async function( req: express.Request, res: expres
|
|||||||
let pws: PWS | undefined = undefined;
|
let pws: PWS | undefined = undefined;
|
||||||
if ( adjustmentOptions.pws && adjustmentOptions.key ) {
|
if ( adjustmentOptions.pws && adjustmentOptions.key ) {
|
||||||
|
|
||||||
const idMatch = adjustmentOptions.pws.match( /^pws:([a-zA-Z\d]+)$/ );
|
const idMatch = adjustmentOptions.pws.match( /^[a-zA-Z\d]+$/ );
|
||||||
const pwsId = idMatch ? idMatch[ 1 ] : undefined;
|
const pwsId = idMatch ? idMatch[ 0 ] : undefined;
|
||||||
const keyMatch = adjustmentOptions.key.match( /^[a-f\d]{32}$/ );
|
const keyMatch = adjustmentOptions.key.match( /^[a-f\d]{32}$/ );
|
||||||
const apiKey = keyMatch ? keyMatch[ 0 ] : undefined;
|
const apiKey = keyMatch ? keyMatch[ 0 ] : undefined;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user