@beinformed/ui 1.43.3 → 1.43.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,14 +45,14 @@ const json = {
45
45
  label: "Description Content",
46
46
  sections: [
47
47
  {
48
- id: "Alert",
48
+ id: "Alert.:-",
49
49
  type: "Reference",
50
50
  label: "Alert",
51
51
  number: "1",
52
52
  body: "<p>The limit of 0.5 per mille has been exceeded.</p>",
53
53
  _links: {
54
54
  self: {
55
- href: "/content/_Context/Police incident decisions/Content/Breath analysis/Breathalyzer test.formalsource/Alert",
55
+ href: "/content/_Context/Police%20incident%20decisions/Content/Breath%20analysis/Breathalyzer%20test.formalsource/Alert.%3A-",
56
56
  },
57
57
  },
58
58
  childSections: [
@@ -183,10 +183,10 @@ describe("AttributeContent", () => {
183
183
  expect(firstSection instanceof SectionModel).toBe(true);
184
184
 
185
185
  expect(firstSection.selflink.href.toString()).toBe(
186
- "/content/_Context/Police incident decisions/Content/Breath analysis/Breathalyzer test.formalsource/Alert",
186
+ "/content/_Context/Police%20incident%20decisions/Content/Breath%20analysis/Breathalyzer%20test.formalsource/Alert.%3A-",
187
187
  );
188
188
  expect(firstSection.selfhref.toString()).toBe(
189
- "/content/_Context/Police incident decisions/Content/Breath analysis/Breathalyzer test.formalsource/Alert",
189
+ "/content/_Context/Police%20incident%20decisions/Content/Breath%20analysis/Breathalyzer%20test.formalsource/Alert.%3A-",
190
190
  );
191
191
 
192
192
  expect(firstSection.type).toBe("Reference");
@@ -197,15 +197,15 @@ describe("AttributeContent", () => {
197
197
  );
198
198
  expect(firstSection.childSectionLinks).toHaveLength(2);
199
199
  expect(firstSection.selfContentLink.selfhref.toString()).toBe(
200
- "/content/_Context/Police incident decisions/Content/Breath analysis/Breathalyzer test.formalsource/Alert",
200
+ "/content/_Context/Police%20incident%20decisions/Content/Breath%20analysis/Breathalyzer%20test.formalsource/Alert.%3A-",
201
201
  );
202
202
  expect(firstSection.selfContentLink.encodedHref.toString()).toBe(
203
- "/content/_Context%2FPolice%20incident%20decisions%2FContent%2FBreath%20analysis%2FBreathalyzer%20test.formalsource/Alert",
203
+ "/content/_Context%2FPolice%2520incident%2520decisions%2FContent%2FBreath%2520analysis%2FBreathalyzer%2520test.formalsource/Alert.%3A-",
204
204
  );
205
205
 
206
206
  expect(firstSection.childSections).toHaveLength(2);
207
207
  expect(firstSection.subSections).toHaveLength(2);
208
- expect(firstSection.referenceHash).toBe(-2144469773);
208
+ expect(firstSection.referenceHash).toBe(-1954774597);
209
209
  });
210
210
 
211
211
  it("can handle referredSections", () => {
@@ -100,24 +100,36 @@ export default class ContentLinkModel
100
100
  }
101
101
 
102
102
  /**
103
- * Encode the content-identifier of the path to the content resource.
104
- * This makes it a single uri part, which can be used on routes to make nested routes
105
103
  */
106
- get encodedHref(): Href {
104
+ createEncodedHref(): Href {
107
105
  const startURI = "/content/";
108
106
  const selfhref = this.data._links.self.href;
107
+
109
108
  const section = this.data.section;
109
+ const sourceId = section
110
+ ? selfhref.substring(startURI.length, selfhref.lastIndexOf("/"))
111
+ : selfhref.substring(startURI.length, selfhref.lastIndexOf("#"));
110
112
 
111
- const path = section
112
- ? `${startURI}${encodeURIComponent(
113
- selfhref.substring(
114
- startURI.length,
115
- selfhref.indexOf(this.data.section) - 1,
116
- ),
117
- )}/${encodeURIComponent(section)}`
118
- : `${startURI}${encodeURIComponent(selfhref.substring(startURI.length))}`;
113
+ let hash = "";
114
+ if (selfhref.hash) {
115
+ hash = `#${selfhref.hash}`;
116
+ }
117
+
118
+ if (section) {
119
+ return new Href(
120
+ `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}${hash}`,
121
+ );
122
+ }
119
123
 
120
- const href = new Href(path);
124
+ return new Href(`${startURI}${encodeURIComponent(sourceId)}${hash}`);
125
+ }
126
+
127
+ /**
128
+ * Encode the content-identifier of the path to the content resource.
129
+ * This makes it a single uri part, which can be used on routes to make nested routes
130
+ */
131
+ get encodedHref(): Href {
132
+ const href = this.createEncodedHref();
121
133
 
122
134
  if (this._entryDate !== null) {
123
135
  return href.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);