diff --git a/packages/lib/src/values/html.ts b/packages/lib/src/values/html.ts index b223c4d..fa106ff 100644 --- a/packages/lib/src/values/html.ts +++ b/packages/lib/src/values/html.ts @@ -58,8 +58,8 @@ const selectCss = (el: AnyHtmlNode, selector: string, expand: boolean) => { } export const select = (el: AnyHtmlNode, selector: string, expand: boolean) => { - return selector.startsWith('xpath:') - ? selectXpath(el, selector.slice(6), expand) + return /^(\/|\.\/)/.test(selector) + ? selectXpath(el, selector, expand) : selectCss(el, selector, expand) } diff --git a/test/calls.spec.ts b/test/calls.spec.ts index 6a618bf..3b4f005 100644 --- a/test/calls.spec.ts +++ b/test/calls.spec.ts @@ -260,8 +260,8 @@ describe('calls', () => { Data: ` inputs { text } - extract xpath://div[p[contains(text(), '$text')]] - -> xpath:@data-json + extract //div[p[contains(text(), '$text')]] + -> ./@data-json -> @json `, } @@ -291,13 +291,13 @@ describe('calls', () => { GET http://stub extract @Data({text: |'first'|}) - -> xpath:@data-json + -> ./@data-json -> @json `, Data: ` inputs { text } - extract xpath://div[p[contains(text(), '$text')]] + extract //div[p[contains(text(), '$text')]] `, } diff --git a/test/request.spec.ts b/test/request.spec.ts index e20fa96..c8f1b90 100644 --- a/test/request.spec.ts +++ b/test/request.spec.ts @@ -396,7 +396,7 @@ describe('request', () => { extract { link1: link -> @link link2: anchor -> @html -> a -> @link - link3: attr -> @html -> i -> xpath:@data-url -> @link + link3: attr -> @html -> i -> ./@data-url -> @link link4: img -> @html -> img -> @link } `, diff --git a/test/slice.spec.ts b/test/slice.spec.ts index 96aafe9..913fbdc 100644 --- a/test/slice.spec.ts +++ b/test/slice.spec.ts @@ -85,7 +85,7 @@ describe('slice', () => { it('converts context to value prior to run', async () => { const result = await execute(` set html = |'
welcome
"| - extract $html -> @html -> xpath://p/@class + extract $html -> @html -> //p/@class `) expect(result).toEqual('intro') }) @@ -204,10 +204,10 @@ describe('values', () => { test.if(SELSYN)('xpath parsing error', async () => { const result = execute(` set html = |'