Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
614 bytes
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Ivan Kopeykin @vankop
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const PATH_QUERY_FRAGMENT_REGEXP = /^(#?(?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * @param {string} identifier identifier
|
---|
12 | * @returns {[string, string, string]|null} parsed identifier
|
---|
13 | */
|
---|
14 | function parseIdentifier(identifier) {
|
---|
15 | const match = PATH_QUERY_FRAGMENT_REGEXP.exec(identifier);
|
---|
16 |
|
---|
17 | if (!match) return null;
|
---|
18 |
|
---|
19 | return [
|
---|
20 | match[1].replace(/\0(.)/g, "$1"),
|
---|
21 | match[2] ? match[2].replace(/\0(.)/g, "$1") : "",
|
---|
22 | match[3] || ""
|
---|
23 | ];
|
---|
24 | }
|
---|
25 |
|
---|
26 | module.exports.parseIdentifier = parseIdentifier;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.